home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Corel 10 Texture (image/corel10Texture)
| ext
| Unsupported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| x-fmt/111 Plain Text File
| default
| |
100%
| detectItEasy
| Format: Plain text[LF]
| default
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 6d 61 67 6e 69 66 69 | 63 61 74 69 6f 6e 20 3d |\magnifi|cation =|
|00000010| 20 5c 6d 61 67 73 74 65 | 70 31 0a 0a 5c 66 6f 6e | \magste|p1..\fon|
|00000020| 74 5c 74 69 74 6c 65 66 | 6f 6e 74 3d 63 6d 62 78 |t\titlef|ont=cmbx|
|00000030| 31 30 20 73 63 61 6c 65 | 64 20 5c 6d 61 67 73 74 |10 scale|d \magst|
|00000040| 65 70 33 20 0a 5c 66 6f | 6e 74 5c 73 65 63 74 69 |ep3 .\fo|nt\secti|
|00000050| 6f 6e 66 6f 6e 74 3d 63 | 6d 72 31 30 20 73 63 61 |onfont=c|mr10 sca|
|00000060| 6c 65 64 20 5c 6d 61 67 | 73 74 65 70 32 0a 5c 66 |led \mag|step2.\f|
|00000070| 6f 6e 74 5c 6d 61 67 6f | 6e 65 3d 63 6d 72 31 30 |ont\mago|ne=cmr10|
|00000080| 20 73 63 61 6c 65 64 20 | 5c 6d 61 67 73 74 65 70 | scaled |\magstep|
|00000090| 31 0a 5c 66 6f 6e 74 5c | 6d 61 67 6f 6e 65 62 66 |1.\font\|magonebf|
|000000a0| 3d 63 6d 62 78 31 30 20 | 73 63 61 6c 65 64 20 5c |=cmbx10 |scaled \|
|000000b0| 6d 61 67 73 74 65 70 31 | 20 0a 5c 66 6f 6e 74 5c |magstep1| .\font\|
|000000c0| 62 69 67 6f 6e 65 3d 63 | 6d 72 31 30 20 73 63 61 |bigone=c|mr10 sca|
|000000d0| 6c 65 64 20 5c 6d 61 67 | 73 74 65 70 31 0a 5c 66 |led \mag|step1.\f|
|000000e0| 6f 6e 74 5c 62 69 67 74 | 77 6f 3d 63 6d 72 31 30 |ont\bigt|wo=cmr10|
|000000f0| 20 73 63 61 6c 65 64 20 | 5c 6d 61 67 73 74 65 70 | scaled |\magstep|
|00000100| 32 0a 5c 66 6f 6e 74 5c | 62 69 67 74 68 72 65 65 |2.\font\|bigthree|
|00000110| 3d 63 6d 72 31 30 20 73 | 63 61 6c 65 64 20 5c 6d |=cmr10 s|caled \m|
|00000120| 61 67 73 74 65 70 33 0a | 5c 66 6f 6e 74 5c 62 69 |agstep3.|\font\bi|
|00000130| 67 66 6f 75 72 3d 63 6d | 72 31 30 20 73 63 61 6c |gfour=cm|r10 scal|
|00000140| 65 64 20 5c 6d 61 67 73 | 74 65 70 34 0a 0a 5c 64 |ed \mags|tep4..\d|
|00000150| 65 66 5c 62 6f 78 69 74 | 23 31 7b 5c 76 62 6f 78 |ef\boxit|#1{\vbox|
|00000160| 7b 5c 68 72 75 6c 65 5c | 68 62 6f 78 7b 5c 76 72 |{\hrule\|hbox{\vr|
|00000170| 75 6c 65 5c 6b 65 72 6e | 33 70 74 5c 76 62 6f 78 |ule\kern|3pt\vbox|
|00000180| 7b 23 31 7d 5c 6b 65 72 | 6e 33 70 74 5c 76 72 75 |{#1}\ker|n3pt\vru|
|00000190| 6c 65 7d 5c 68 72 75 6c | 65 7d 7d 0a 0a 5c 64 65 |le}\hrul|e}}..\de|
|000001a0| 66 5c 43 43 7b 43 5c 72 | 61 69 73 65 2e 30 38 65 |f\CC{C\r|aise.08e|
|000001b0| 78 5c 68 62 6f 78 7b 5c | 74 74 20 2b 2b 5c 20 7d |x\hbox{\|tt ++\ }|
|000001c0| 7d 0a 5c 64 65 66 5c 43 | 43 43 7b 43 5c 72 61 69 |}.\def\C|CC{C\rai|
|000001d0| 73 65 2e 30 38 65 78 5c | 68 62 6f 78 7b 5c 74 74 |se.08ex\|hbox{\tt|
|000001e0| 20 2b 2b 7d 7d 0a 5c 64 | 65 66 5c 67 67 7b 67 5c | ++}}.\d|ef\gg{g\|
|000001f0| 68 62 6f 78 7b 5c 74 74 | 20 2b 2b 5c 20 7d 7d 0a |hbox{\tt| ++\ }}.|
|00000200| 5c 64 65 66 5c 6e 61 74 | 7b 5c 68 62 6f 78 7b 5c |\def\nat|{\hbox{\|
|00000210| 72 6d 5c 76 72 75 6c 65 | 5c 6b 65 72 6e 2d 30 2e |rm\vrule|\kern-0.|
|00000220| 30 34 35 65 6d 20 4e 7d | 7d 0a 5c 64 65 66 5c 72 |045em N}|}.\def\r|
|00000230| 65 61 6c 7b 5c 68 62 6f | 78 7b 5c 72 6d 5c 76 72 |eal{\hbo|x{\rm\vr|
|00000240| 75 6c 65 5c 6b 65 72 6e | 2d 30 2e 30 33 35 65 6d |ule\kern|-0.035em|
|00000250| 20 52 7d 7d 0a 5c 64 65 | 66 5c 6e 6c 7b 5c 68 66 | R}}.\de|f\nl{\hf|
|00000260| 69 6c 6c 5c 62 72 65 61 | 6b 7d 0a 5c 64 65 66 5c |ill\brea|k}.\def\|
|00000270| 27 7b 5e 5c 70 72 69 6d | 65 7d 0a 5c 64 65 66 5c |'{^\prim|e}.\def\|
|00000280| 62 65 67 69 6e 69 74 65 | 6d 20 20 20 7b 5c 70 61 |beginite|m {\pa|
|00000290| 72 69 6e 64 65 6e 74 20 | 32 30 70 74 20 7d 0a 5c |rindent |20pt }.\|
|000002a0| 64 65 66 5c 65 6e 64 69 | 74 65 6d 20 20 20 20 20 |def\endi|tem |
|000002b0| 7b 5c 70 61 72 69 6e 64 | 65 6e 74 20 30 70 74 20 |{\parind|ent 0pt |
|000002c0| 7d 0a 5c 64 65 66 5c 72 | 65 66 73 74 61 72 74 20 |}.\def\r|efstart |
|000002d0| 23 31 20 7b 5c 70 61 72 | 69 6e 64 65 6e 74 20 23 |#1 {\par|indent #|
|000002e0| 31 20 7d 0a 5c 64 65 66 | 5c 72 65 66 65 6e 64 20 |1 }.\def|\refend |
|000002f0| 20 20 20 20 20 7b 5c 70 | 61 72 69 6e 64 65 6e 74 | {\p|arindent|
|00000300| 20 30 70 74 20 7d 0a 5c | 64 65 66 5c 72 65 66 20 | 0pt }.\|def\ref |
|00000310| 23 31 20 23 32 20 20 20 | 7b 5c 69 74 65 6d 20 7b |#1 #2 |{\item {|
|00000320| 5c 68 62 6f 78 20 74 6f | 20 5c 70 61 72 69 6e 64 |\hbox to| \parind|
|00000330| 65 6e 74 20 7b 5c 62 66 | 20 5c 20 5b 23 31 5d 20 |ent {\bf| \ [#1] |
|00000340| 5c 68 66 69 6c 6c 7d 7d | 20 23 32 7d 0a 0a 0a 5c |\hfill}}| #2}...\|
|00000350| 64 65 66 5c 6f 70 20 20 | 23 31 20 23 32 20 23 33 |def\op |#1 #2 #3|
|00000360| 20 23 34 20 7b 26 20 24 | 23 31 24 20 26 20 5c 76 | #4 {& $|#1$ & \v|
|00000370| 61 72 2e 23 32 28 24 23 | 33 24 29 20 20 20 26 20 |ar.#2($#|3$) & |
|00000380| 23 34 5c 63 72 7d 0a 5c | 64 65 66 5c 6e 6f 70 20 |#4\cr}.\|def\nop |
|00000390| 23 31 20 20 20 20 20 20 | 20 20 20 20 7b 26 20 20 |#1 | {& |
|000003a0| 20 20 20 20 26 20 20 20 | 20 20 20 20 20 20 20 20 | & | |
|000003b0| 20 20 20 20 20 20 26 20 | 23 31 5c 63 72 7d 0a 5c | & |#1\cr}.\|
|000003c0| 64 65 66 5c 64 65 63 6c | 20 23 31 20 23 32 20 0a |def\decl| #1 #2 .|
|000003d0| 7b 7b 5c 62 66 20 64 65 | 63 6c 61 72 65 7d 28 24 |{{\bf de|clare}($|
|000003e0| 23 31 2c 20 23 32 24 29 | 20 5c 64 65 66 5c 74 79 |#1, #2$)| \def\ty|
|000003f0| 70 65 20 7b 23 31 7d 20 | 5c 64 65 66 5c 6e 61 6d |pe {#1} |\def\nam|
|00000400| 65 20 7b 24 23 31 28 23 | 32 29 24 7d 20 7d 0a 5c |e {$#1(#|2)$} }.\|
|00000410| 64 65 66 5c 64 65 63 6c | 74 77 6f 20 23 31 20 23 |def\decl|two #1 #|
|00000420| 32 20 23 33 20 0a 7b 7b | 5c 62 66 20 64 65 63 6c |2 #3 .{{|\bf decl|
|00000430| 61 72 65 32 7d 28 24 23 | 31 2c 20 23 32 2c 20 23 |are2}($#|1, #2, #|
|00000440| 33 24 29 20 5c 64 65 66 | 5c 74 79 70 65 20 7b 23 |3$) \def|\type {#|
|00000450| 31 7d 20 5c 64 65 66 5c | 6e 61 6d 65 20 7b 24 23 |1} \def\|name {$#|
|00000460| 31 28 23 32 2c 23 33 29 | 24 7d 20 7d 0a 5c 64 65 |1(#2,#3)|$} }.\de|
|00000470| 66 5c 64 65 63 6c 74 68 | 72 65 65 20 23 31 20 23 |f\declth|ree #1 #|
|00000480| 32 20 23 33 20 23 34 0a | 7b 7b 5c 62 66 20 64 65 |2 #3 #4.|{{\bf de|
|00000490| 63 6c 61 72 65 32 7d 28 | 24 23 31 2c 20 23 32 2c |clare2}(|$#1, #2,|
|000004a0| 20 23 33 2c 20 23 34 24 | 29 20 5c 64 65 66 5c 74 | #3, #4$|) \def\t|
|000004b0| 79 70 65 20 7b 23 31 7d | 20 5c 64 65 66 5c 6e 61 |ype {#1}| \def\na|
|000004c0| 6d 65 20 7b 24 23 31 28 | 23 32 2c 23 33 2c 23 34 |me {$#1(|#2,#3,#4|
|000004d0| 29 24 7d 20 7d 0a 5c 64 | 65 66 5c 63 72 65 61 74 |)$} }.\d|ef\creat|
|000004e0| 65 20 23 31 20 23 32 20 | 7b 20 5c 6e 61 6d 65 5c |e #1 #2 |{ \name\|
|000004f0| 20 5c 20 24 23 31 20 23 | 32 24 3b 20 5c 64 65 66 | \ $#1 #|2$; \def|
|00000500| 5c 76 61 72 20 7b 24 23 | 31 24 7d 20 7d 0a 5c 64 |\var {$#|1$} }.\d|
|00000510| 65 66 5c 6f 70 65 72 61 | 74 69 6f 6e 73 20 20 7b |ef\opera|tions {|
|00000520| 4f 70 65 72 61 74 69 6f | 6e 73 20 6f 6e 20 61 20 |Operatio|ns on a |
|00000530| 5c 74 79 70 65 5c 20 5c | 76 61 72 7d 0a 5c 64 65 |\type\ \|var}.\de|
|00000540| 66 5c 70 72 65 63 6f 6e | 64 20 7b 7b 5c 69 74 20 |f\precon|d {{\it |
|00000550| 50 72 65 63 6f 6e 64 69 | 74 69 6f 6e 7d 3a 20 7d |Precondi|tion}: }|
|00000560| 0a 5c 64 65 66 5c 6e 20 | 7b 24 5c 62 61 63 6b 73 |.\def\n |{$\backs|
|00000570| 6c 61 73 68 24 6e 7d 0a | 0a 5c 64 65 66 5c 62 6f |lash$n}.|.\def\bo|
|00000580| 78 69 74 23 31 7b 5c 76 | 62 6f 78 7b 5c 68 72 75 |xit#1{\v|box{\hru|
|00000590| 6c 65 5c 68 62 6f 78 7b | 5c 76 72 75 6c 65 5c 6b |le\hbox{|\vrule\k|
|000005a0| 65 72 6e 33 70 74 5c 76 | 62 6f 78 7b 23 31 7d 5c |ern3pt\v|box{#1}\|
|000005b0| 6b 65 72 6e 33 70 74 5c | 76 72 75 6c 65 7d 5c 68 |kern3pt\|vrule}\h|
|000005c0| 72 75 6c 65 7d 7d 0a 0a | 5c 64 65 66 5c 57 48 49 |rule}}..|\def\WHI|
|000005d0| 4c 45 20 7b 7b 5c 62 66 | 20 77 68 69 6c 65 7d 5c |LE {{\bf| while}\|
|000005e0| 20 7d 0a 5c 64 65 66 5c | 49 46 20 7b 7b 5c 62 66 | }.\def\|IF {{\bf|
|000005f0| 20 69 66 7d 5c 20 7d 0a | 5c 64 65 66 5c 45 4c 53 | if}\ }.|\def\ELS|
|00000600| 45 20 7b 7b 5c 62 66 20 | 65 6c 73 65 5c 20 7d 7d |E {{\bf |else\ }}|
|00000610| 0a 0a 0a 0a 5c 68 73 69 | 7a 65 3d 31 37 20 74 72 |....\hsi|ze=17 tr|
|00000620| 75 65 63 6d 0a 5c 76 73 | 69 7a 65 3d 32 34 2e 35 |uecm.\vs|ize=24.5|
|00000630| 20 74 72 75 65 63 6d 0a | 0a 5c 68 6f 66 66 73 65 | truecm.|.\hoffse|
|00000640| 74 3d 31 2e 35 74 72 75 | 65 63 6d 0a 5c 76 6f 66 |t=1.5tru|ecm.\vof|
|00000650| 66 73 65 74 3d 31 2e 36 | 74 72 75 65 63 6d 0a 0a |fset=1.6|truecm..|
|00000660| 5c 70 61 72 69 6e 64 65 | 6e 74 20 30 70 74 0a 5c |\parinde|nt 0pt.\|
|00000670| 70 61 72 73 6b 69 70 20 | 38 70 74 20 70 6c 75 73 |parskip |8pt plus|
|00000680| 20 31 70 74 20 6d 69 6e | 75 73 20 31 70 74 20 0a | 1pt min|us 1pt .|
|00000690| 0a 0a 0a 5c 76 67 6c 75 | 65 20 31 74 72 75 65 63 |...\vglu|e 1truec|
|000006a0| 6d 0a 5c 63 65 6e 74 65 | 72 6c 69 6e 65 7b 7b 5c |m.\cente|rline{{\|
|000006b0| 6d 61 67 6f 6e 65 62 66 | 20 4c 45 44 41 7d 7d 0a |magonebf| LEDA}}.|
|000006c0| 5c 76 67 6c 75 65 20 2e | 35 74 72 75 65 63 6d 0a |\vglue .|5truecm.|
|000006d0| 5c 63 65 6e 74 65 72 6c | 69 6e 65 7b 7b 5c 6d 61 |\centerl|ine{{\ma|
|000006e0| 67 6f 6e 65 62 66 20 41 | 20 4c 69 62 72 61 72 79 |gonebf A| Library|
|000006f0| 20 6f 66 20 45 66 66 69 | 63 69 65 6e 74 20 44 61 | of Effi|cient Da|
|00000700| 74 61 20 54 79 70 65 73 | 20 61 6e 64 20 41 6c 67 |ta Types| and Alg|
|00000710| 6f 72 69 74 68 6d 73 7d | 0a 5c 66 6f 6f 74 6e 6f |orithms}|.\footno|
|00000720| 74 65 7b 2a 7d 0a 7b 54 | 68 69 73 20 72 65 73 65 |te{*}.{T|his rese|
|00000730| 61 72 63 68 20 77 61 73 | 20 73 75 70 70 6f 72 74 |arch was| support|
|00000740| 65 64 20 62 79 20 74 68 | 65 20 45 53 50 52 49 54 |ed by th|e ESPRIT|
|00000750| 20 49 49 20 42 61 73 69 | 63 20 52 65 73 65 61 72 | II Basi|c Resear|
|00000760| 63 68 20 41 63 74 69 6f | 6e 20 50 72 6f 67 72 61 |ch Actio|n Progra|
|00000770| 6d 2c 20 0a 45 53 50 52 | 49 54 20 5c 20 50 2e 20 |m, .ESPR|IT \ P. |
|00000780| 33 30 37 35 20 2d 2d 20 | 41 4c 43 4f 4d 2e 20 4d |3075 -- |ALCOM. M|
|00000790| 6f 73 74 20 6f 66 20 74 | 68 69 73 20 77 6f 72 6b |ost of t|his work|
|000007a0| 20 77 61 73 20 63 61 72 | 72 69 65 64 20 6f 75 74 | was car|ried out|
|000007b0| 20 77 68 69 6c 65 20 74 | 68 65 20 61 75 74 68 6f | while t|he autho|
|000007c0| 72 73 0a 77 65 72 65 20 | 61 66 66 69 6c 69 61 74 |rs.were |affiliat|
|000007d0| 65 64 20 77 69 74 68 20 | 46 61 63 68 62 65 72 65 |ed with |Fachbere|
|000007e0| 69 63 68 20 49 6e 66 6f | 72 6d 61 74 69 6b 2c 20 |ich Info|rmatik, |
|000007f0| 55 6e 69 76 65 72 73 69 | 74 5c 22 61 74 20 64 65 |Universi|t\"at de|
|00000800| 73 20 53 61 61 72 6c 61 | 6e 64 65 73 2e 7d 7d 0a |s Saarla|ndes.}}.|
|00000810| 5c 76 67 6c 75 65 20 31 | 74 72 75 65 63 6d 0a 5c |\vglue 1|truecm.\|
|00000820| 63 65 6e 74 65 72 6c 69 | 6e 65 7b 4b 75 72 74 20 |centerli|ne{Kurt |
|00000830| 4d 65 68 6c 68 6f 72 6e | 20 61 6e 64 20 53 74 65 |Mehlhorn| and Ste|
|00000840| 66 61 6e 20 4e 5c 22 61 | 68 65 72 7d 0a 5c 76 67 |fan N\"a|her}.\vg|
|00000850| 6c 75 65 20 2e 35 74 72 | 75 65 63 6d 0a 5c 63 65 |lue .5tr|uecm.\ce|
|00000860| 6e 74 65 72 6c 69 6e 65 | 7b 4d 61 78 2d 50 6c 61 |nterline|{Max-Pla|
|00000870| 6e 63 6b 2d 49 6e 73 74 | 69 74 75 74 20 66 5c 22 |nck-Inst|itut f\"|
|00000880| 75 72 20 49 6e 66 6f 72 | 6d 61 74 69 6b 7d 0a 5c |ur Infor|matik}.\|
|00000890| 63 65 6e 74 65 72 6c 69 | 6e 65 7b 44 2d 36 36 30 |centerli|ne{D-660|
|000008a0| 30 20 53 61 61 72 62 72 | 5c 22 75 63 6b 65 6e 2c |0 Saarbr|\"ucken,|
|000008b0| 20 46 65 64 65 72 61 6c | 20 52 65 70 75 62 6c 69 | Federal| Republi|
|000008c0| 63 20 6f 66 20 47 65 72 | 6d 61 6e 79 7d 0a 5c 76 |c of Ger|many}.\v|
|000008d0| 67 6c 75 65 20 31 74 72 | 75 65 63 6d 20 0a 7b 5c |glue 1tr|uecm .{\|
|000008e0| 62 66 20 4b 65 79 20 77 | 6f 72 64 73 7d 3a 20 61 |bf Key w|ords}: a|
|000008f0| 62 73 74 72 61 63 74 20 | 64 61 74 61 20 74 79 70 |bstract |data typ|
|00000900| 65 2c 20 72 65 75 73 61 | 62 6c 65 20 73 6f 66 74 |e, reusa|ble soft|
|00000910| 77 61 72 65 2c 20 65 66 | 66 69 63 69 65 6e 74 20 |ware, ef|ficient |
|00000920| 61 6c 67 6f 72 69 74 68 | 6d 73 2c 0a 6f 62 6a 65 |algorith|ms,.obje|
|00000930| 63 74 20 6f 72 69 65 6e | 74 65 64 20 70 72 6f 67 |ct orien|ted prog|
|00000940| 72 61 6d 6d 69 6e 67 0a | 5c 76 67 6c 75 65 20 31 |ramming.|\vglue 1|
|00000950| 74 72 75 65 63 6d 20 0a | 5c 63 65 6e 74 65 72 6c |truecm .|\centerl|
|00000960| 69 6e 65 7b 5c 62 66 20 | 41 62 73 74 72 61 63 74 |ine{\bf |Abstract|
|00000970| 7d 0a 7b 5c 70 61 72 69 | 6e 64 65 6e 74 20 31 2e |}.{\pari|ndent 1.|
|00000980| 35 74 72 75 65 63 6d 0a | 7b 5c 6e 61 72 72 6f 77 |5truecm.|{\narrow|
|00000990| 65 72 5c 73 6d 61 6c 6c | 73 6b 69 70 5c 6e 6f 69 |er\small|skip\noi|
|000009a0| 6e 64 65 6e 74 0a 4c 45 | 44 41 20 69 73 20 61 20 |ndent.LE|DA is a |
|000009b0| 6c 69 62 72 61 72 79 20 | 6f 66 20 65 66 66 69 63 |library |of effic|
|000009c0| 69 65 6e 74 20 64 61 74 | 61 20 74 79 70 65 73 20 |ient dat|a types |
|000009d0| 61 6e 64 20 61 6c 67 6f | 72 69 74 68 6d 73 2e 0a |and algo|rithms..|
|000009e0| 41 74 20 70 72 65 73 65 | 6e 74 2c 20 69 74 73 20 |At prese|nt, its |
|000009f0| 73 74 72 65 6e 67 74 68 | 20 69 73 20 67 72 61 70 |strength| is grap|
|00000a00| 68 20 61 6c 67 6f 72 69 | 74 68 6d 73 20 61 6e 64 |h algori|thms and|
|00000a10| 20 72 65 6c 61 74 65 64 | 20 64 61 74 61 0a 73 74 | related| data.st|
|00000a20| 72 75 63 74 75 72 65 73 | 2e 20 54 68 65 20 63 6f |ructures|. The co|
|00000a30| 6d 70 75 74 61 74 69 6f | 6e 61 6c 20 67 65 6f 6d |mputatio|nal geom|
|00000a40| 65 74 72 79 20 70 61 72 | 74 20 69 73 20 65 76 6f |etry par|t is evo|
|00000a50| 6c 76 69 6e 67 2e 0a 54 | 68 65 20 6d 61 69 6e 20 |lving..T|he main |
|00000a60| 66 65 61 74 75 72 65 73 | 20 6f 66 20 74 68 65 20 |features| of the |
|00000a70| 6c 69 62 72 61 72 79 20 | 61 72 65 20 0a 5c 73 6d |library |are .\sm|
|00000a80| 61 6c 6c 73 6b 69 70 5c | 6e 6f 69 6e 64 65 6e 74 |allskip\|noindent|
|00000a90| 0a 2d 2d 20 61 20 73 69 | 7a 61 62 6c 65 20 63 6f |.-- a si|zable co|
|00000aa0| 6c 6c 65 63 74 69 6f 6e | 20 6f 66 20 64 61 74 61 |llection| of data|
|00000ab0| 20 74 79 70 65 73 20 61 | 6e 64 20 61 6c 67 6f 72 | types a|nd algor|
|00000ac0| 69 74 68 6d 73 2c 5c 6e | 6c 0a 2d 2d 20 74 68 65 |ithms,\n|l.-- the|
|00000ad0| 20 70 72 65 63 69 73 65 | 20 61 6e 64 20 72 65 61 | precise| and rea|
|00000ae0| 64 61 62 6c 65 20 73 70 | 65 63 69 66 69 63 61 74 |dable sp|ecificat|
|00000af0| 69 6f 6e 20 6f 66 20 74 | 68 65 73 65 20 74 79 70 |ion of t|hese typ|
|00000b00| 65 73 2c 5c 6e 6c 0a 2d | 2d 20 74 68 65 20 69 6e |es,\nl.-|- the in|
|00000b10| 63 6c 75 73 69 6f 6e 20 | 6f 66 20 6d 61 6e 79 20 |clusion |of many |
|00000b20| 6f 66 20 74 68 65 20 6d | 6f 73 74 20 72 65 63 65 |of the m|ost rece|
|00000b30| 6e 74 20 61 6e 64 20 65 | 66 66 69 63 69 65 6e 74 |nt and e|fficient|
|00000b40| 20 69 6d 70 6c 65 6d 65 | 6e 74 61 74 69 6f 6e 73 | impleme|ntations|
|00000b50| 2c 5c 6e 6c 0a 2d 2d 20 | 61 20 63 6f 6d 66 6f 72 |,\nl.-- |a comfor|
|00000b60| 74 61 62 6c 65 20 64 61 | 74 61 20 74 79 70 65 20 |table da|ta type |
|00000b70| 67 72 61 70 68 2c 5c 6e | 6c 0a 2d 2d 20 69 74 73 |graph,\n|l.-- its|
|00000b80| 20 65 78 74 65 6e 64 69 | 62 69 6c 69 74 79 2c 20 | extendi|bility, |
|00000b90| 61 6e 64 5c 6e 6c 0a 2d | 2d 20 69 74 73 20 65 61 |and\nl.-|- its ea|
|00000ba0| 73 65 20 6f 66 20 75 73 | 65 2e 0a 5c 73 6d 61 6c |se of us|e..\smal|
|00000bb0| 6c 73 6b 69 70 7d 7d 0a | 0a 0a 5c 62 69 67 73 6b |lskip}}.|..\bigsk|
|00000bc0| 69 70 0a 7b 5c 6d 61 67 | 6f 6e 65 62 66 20 49 2e |ip.{\mag|onebf I.|
|00000bd0| 20 49 6e 74 72 6f 64 75 | 63 74 69 6f 6e 7d 0a 0a | Introdu|ction}..|
|00000be0| 54 68 65 72 65 20 69 73 | 20 6e 6f 20 73 74 61 6e |There is| no stan|
|00000bf0| 64 61 72 64 20 6c 69 62 | 72 61 72 79 20 6f 66 20 |dard lib|rary of |
|00000c00| 74 68 65 20 64 61 74 61 | 20 73 74 72 75 63 74 75 |the data| structu|
|00000c10| 72 65 73 20 61 6e 64 0a | 61 6c 67 6f 72 69 74 68 |res and.|algorith|
|00000c20| 6d 73 20 6f 66 20 63 6f | 6d 62 69 6e 61 74 6f 72 |ms of co|mbinator|
|00000c30| 69 61 6c 20 63 6f 6d 70 | 75 74 69 6e 67 2e 0a 54 |ial comp|uting..T|
|00000c40| 68 69 73 20 69 73 20 69 | 6e 20 73 68 61 72 70 20 |his is i|n sharp |
|00000c50| 63 6f 6e 74 72 61 73 74 | 20 74 6f 20 6d 61 6e 79 |contrast| to many|
|00000c60| 20 6f 74 68 65 72 20 61 | 72 65 61 73 20 6f 66 20 | other a|reas of |
|00000c70| 63 6f 6d 70 75 74 69 6e | 67 2e 0a 54 68 65 72 65 |computin|g..There|
|00000c80| 20 61 72 65 2c 20 65 2e | 67 2e 2c 20 70 61 63 6b | are, e.|g., pack|
|00000c90| 61 67 65 73 20 69 6e 20 | 73 74 61 74 69 73 74 69 |ages in |statisti|
|00000ca0| 63 73 20 28 53 50 53 53 | 29 2c 20 6e 75 6d 65 72 |cs (SPSS|), numer|
|00000cb0| 69 63 61 6c 0a 61 6e 61 | 6c 79 73 69 73 20 28 4c |ical.ana|lysis (L|
|00000cc0| 49 4e 50 41 43 4b 2c 20 | 45 49 53 50 41 43 4b 29 |INPACK, |EISPACK)|
|00000cd0| 2c 20 73 79 6d 62 6f 6c | 69 63 20 63 6f 6d 70 75 |, symbol|ic compu|
|00000ce0| 74 61 74 69 6f 6e 0a 28 | 4d 41 43 53 59 4d 41 2c |tation.(|MACSYMA,|
|00000cf0| 20 53 41 43 2d 32 29 20 | 61 6e 64 20 6c 69 6e 65 | SAC-2) |and line|
|00000d00| 61 72 20 70 72 6f 67 72 | 61 6d 6d 69 6e 67 20 28 |ar progr|amming (|
|00000d10| 4d 50 53 58 29 2e 0a 0a | 49 6e 20 66 61 63 74 20 |MPSX)...|In fact |
|00000d20| 74 68 65 20 73 69 74 75 | 61 74 69 6f 6e 20 69 73 |the situ|ation is|
|00000d30| 20 77 6f 72 73 65 2c 20 | 73 69 6e 63 65 20 65 76 | worse, |since ev|
|00000d40| 65 6e 20 77 69 74 68 69 | 6e 20 73 6d 61 6c 6c 20 |en withi|n small |
|00000d50| 67 72 6f 75 70 73 2c 0a | 73 61 79 20 74 68 65 20 |groups,.|say the |
|00000d60| 61 6c 67 6f 72 69 74 68 | 6d 73 20 67 72 6f 75 70 |algorith|ms group|
|00000d70| 20 61 74 0a 6f 75 72 20 | 68 6f 6d 65 20 69 6e 73 | at.our |home ins|
|00000d80| 74 69 74 75 74 69 6f 6e | 2c 20 73 6f 66 74 77 61 |titution|, softwa|
|00000d90| 72 65 20 66 72 65 71 75 | 65 6e 74 6c 79 20 69 73 |re frequ|ently is|
|00000da0| 20 6e 6f 74 20 73 68 61 | 72 65 64 2e 0a 52 61 74 | not sha|red..Rat|
|00000db0| 68 65 72 2c 20 65 61 63 | 68 20 72 65 73 65 61 72 |her, eac|h resear|
|00000dc0| 63 68 65 72 20 73 74 61 | 72 74 73 20 66 72 6f 6d |cher sta|rts from|
|00000dd0| 20 73 63 72 61 74 63 68 | 20 61 6e 64 2c 20 65 2e | scratch| and, e.|
|00000de0| 67 2e 2c 20 64 65 76 65 | 6c 6f 70 73 0a 68 69 73 |g., deve|lops.his|
|00000df0| 20 6f 77 6e 20 76 65 72 | 73 69 6f 6e 20 6f 66 20 | own ver|sion of |
|00000e00| 61 20 62 61 6c 61 6e 63 | 65 64 20 74 72 65 65 2e |a balanc|ed tree.|
|00000e10| 0a 4f 66 20 63 6f 75 72 | 73 65 2c 20 74 68 69 73 |.Of cour|se, this|
|00000e20| 20 63 6f 6e 74 69 6e 75 | 6f 75 73 20 60 60 72 65 | continu|ous ``re|
|00000e30| 69 6d 70 6c 65 6d 65 6e | 74 61 74 69 6f 6e 20 6f |implemen|tation o|
|00000e40| 66 20 74 68 65 20 77 68 | 65 65 6c 27 27 20 73 6c |f the wh|eel'' sl|
|00000e50| 6f 77 73 0a 64 6f 77 6e | 20 70 72 6f 67 72 65 73 |ows.down| progres|
|00000e60| 73 2c 20 77 69 74 68 69 | 6e 20 72 65 73 65 61 72 |s, withi|n resear|
|00000e70| 63 68 20 61 6e 64 20 65 | 76 65 6e 20 6d 6f 72 65 |ch and e|ven more|
|00000e80| 20 73 6f 0a 6f 75 74 73 | 69 64 65 2e 0a 54 68 69 | so.outs|ide..Thi|
|00000e90| 73 20 69 73 20 64 75 65 | 20 74 6f 20 74 68 65 20 |s is due| to the |
|00000ea0| 66 61 63 74 20 74 68 61 | 74 20 6f 75 74 73 69 64 |fact tha|t outsid|
|00000eb0| 65 20 72 65 73 65 61 72 | 63 68 20 74 68 65 20 69 |e resear|ch the i|
|00000ec0| 6e 76 65 73 74 6d 65 6e | 74 0a 66 6f 72 20 69 6d |nvestmen|t.for im|
|00000ed0| 70 6c 65 6d 65 6e 74 69 | 6e 67 20 61 6e 20 65 66 |plementi|ng an ef|
|00000ee0| 66 69 63 69 65 6e 74 20 | 73 6f 6c 75 74 69 6f 6e |ficient |solution|
|00000ef0| 20 66 72 65 71 75 65 6e | 74 6c 79 20 69 73 20 6e | frequen|tly is n|
|00000f00| 6f 74 20 6d 61 64 65 2c | 0a 62 65 63 61 75 73 65 |ot made,|.because|
|00000f10| 20 69 74 20 69 73 20 64 | 6f 75 62 74 66 75 6c 20 | it is d|oubtful |
|00000f20| 77 68 65 74 68 65 72 20 | 74 68 65 20 69 6d 70 6c |whether |the impl|
|00000f30| 65 6d 65 6e 74 61 74 69 | 6f 6e 20 63 61 6e 20 62 |ementati|on can b|
|00000f40| 65 20 72 65 75 73 65 64 | 2c 0a 61 6e 64 20 74 68 |e reused|,.and th|
|00000f50| 65 72 65 66 6f 72 65 20 | 6d 65 74 68 6f 64 73 20 |erefore |methods |
|00000f60| 77 68 69 63 68 20 61 72 | 65 20 6b 6e 6f 77 6e 20 |which ar|e known |
|00000f70| 74 6f 20 62 65 20 6c 65 | 73 73 20 65 66 66 69 63 |to be le|ss effic|
|00000f80| 69 65 6e 74 20 61 72 65 | 0a 75 73 65 64 20 69 6e |ient are|.used in|
|00000f90| 73 74 65 61 64 2e 0a 54 | 68 75 73 20 74 68 65 20 |stead..T|hus the |
|00000fa0| 73 63 69 65 6e 74 69 66 | 69 63 20 64 69 73 63 6f |scientif|ic disco|
|00000fb0| 76 65 72 69 65 73 20 6d | 69 67 72 61 74 65 20 6f |veries m|igrate o|
|00000fc0| 6e 6c 79 20 73 6c 6f 77 | 6c 79 20 69 6e 74 6f 0a |nly slow|ly into.|
|00000fd0| 70 72 61 63 74 69 63 65 | 2e 0a 0a 4f 6e 65 20 6f |practice|...One o|
|00000fe0| 66 20 74 68 65 20 6d 61 | 6a 6f 72 20 64 69 66 66 |f the ma|jor diff|
|00000ff0| 65 72 65 6e 63 65 73 20 | 62 65 74 77 65 65 6e 20 |erences |between |
|00001000| 63 6f 6d 62 69 6e 61 74 | 6f 72 69 61 6c 20 63 6f |combinat|orial co|
|00001010| 6d 70 75 74 69 6e 67 0a | 61 6e 64 20 6f 74 68 65 |mputing.|and othe|
|00001020| 72 20 61 72 65 61 73 20 | 6f 66 20 63 6f 6d 70 75 |r areas |of compu|
|00001030| 74 69 6e 67 20 73 75 63 | 68 20 61 73 20 73 74 61 |ting suc|h as sta|
|00001040| 74 69 73 74 69 63 73 2c | 20 6e 75 6d 65 72 69 63 |tistics,| numeric|
|00001050| 61 6c 0a 61 6e 61 6c 79 | 73 69 73 20 61 6e 64 20 |al.analy|sis and |
|00001060| 6c 69 6e 65 61 72 20 70 | 72 6f 67 72 61 6d 6d 69 |linear p|rogrammi|
|00001070| 6e 67 20 69 73 20 74 68 | 65 20 75 73 65 0a 6f 66 |ng is th|e use.of|
|00001080| 20 63 6f 6d 70 6c 65 78 | 20 64 61 74 61 20 74 79 | complex| data ty|
|00001090| 70 65 73 2e 0a 57 68 69 | 6c 73 74 20 74 68 65 20 |pes..Whi|lst the |
|000010a0| 62 75 69 6c 74 2d 69 6e | 20 74 79 70 65 73 2c 20 |built-in| types, |
|000010b0| 73 75 63 68 20 61 73 20 | 69 6e 74 65 67 65 72 73 |such as |integers|
|000010c0| 2c 20 72 65 61 6c 73 2c | 20 76 65 63 74 6f 72 73 |, reals,| vectors|
|000010d0| 2c 20 61 6e 64 20 6d 61 | 74 72 69 63 65 73 2c 0a |, and ma|trices,.|
|000010e0| 75 73 75 61 6c 6c 79 20 | 73 75 66 66 69 63 65 20 |usually |suffice |
|000010f0| 69 6e 20 74 68 65 20 6f | 74 68 65 72 20 61 72 65 |in the o|ther are|
|00001100| 61 73 2c 20 63 6f 6d 62 | 69 6e 61 74 6f 72 69 61 |as, comb|inatoria|
|00001110| 6c 20 0a 63 6f 6d 70 75 | 74 69 6e 67 20 72 65 6c |l .compu|ting rel|
|00001120| 69 65 73 20 68 65 61 76 | 69 6c 79 20 6f 6e 20 74 |ies heav|ily on t|
|00001130| 79 70 65 73 20 6c 69 6b | 65 20 73 74 61 63 6b 73 |ypes lik|e stacks|
|00001140| 2c 20 71 75 65 75 65 73 | 2c 20 64 69 63 74 69 6f |, queues|, dictio|
|00001150| 6e 61 72 69 65 73 2c 0a | 73 65 71 75 65 6e 63 65 |naries,.|sequence|
|00001160| 73 2c 20 73 6f 72 74 65 | 64 20 73 65 71 75 65 6e |s, sorte|d sequen|
|00001170| 63 65 73 2c 20 70 72 69 | 6f 72 69 74 79 20 71 75 |ces, pri|ority qu|
|00001180| 65 75 65 73 2c 20 67 72 | 61 70 68 73 2c 20 70 6f |eues, gr|aphs, po|
|00001190| 69 6e 74 73 2c 0a 70 6c | 61 6e 65 73 2c 20 24 5c |ints,.pl|anes, $\|
|000011a0| 6c 64 6f 74 73 24 0a 0a | 0a 0a 49 6e 20 31 39 38 |ldots$..|..In 198|
|000011b0| 39 2c 20 77 65 20 73 74 | 61 72 74 65 64 20 61 20 |9, we st|arted a |
|000011c0| 70 72 6f 6a 65 63 74 20 | 28 63 61 6c 6c 65 64 20 |project |(called |
|000011d0| 4c 45 44 41 2c 20 66 6f | 72 20 4c 69 62 72 61 72 |LEDA, fo|r Librar|
|000011e0| 79 20 6f 66 0a 45 66 66 | 69 63 69 65 6e 74 20 44 |y of.Eff|icient D|
|000011f0| 61 74 61 20 74 79 70 65 | 73 20 61 6e 64 20 41 6c |ata type|s and Al|
|00001200| 67 6f 72 69 74 68 6d 73 | 29 20 74 6f 20 62 75 69 |gorithms|) to bui|
|00001210| 6c 64 20 61 20 6c 69 62 | 72 61 72 79 20 6f 66 0a |ld a lib|rary of.|
|00001220| 74 68 65 20 64 61 74 61 | 20 74 79 70 65 73 20 61 |the data| types a|
|00001230| 6e 64 20 61 6c 67 6f 72 | 69 74 68 6d 73 20 6f 66 |nd algor|ithms of|
|00001240| 20 63 6f 6d 62 69 6e 61 | 74 6f 72 69 61 6c 20 63 | combina|torial c|
|00001250| 6f 6d 70 75 74 69 6e 67 | 2e 20 54 68 65 0a 66 65 |omputing|. The.fe|
|00001260| 61 74 75 72 65 73 20 6f | 66 20 4c 45 44 41 20 61 |atures o|f LEDA a|
|00001270| 72 65 3a 0a 0a 5c 62 65 | 67 69 6e 69 74 65 6d 0a |re:..\be|ginitem.|
|00001280| 5c 69 74 65 6d 7b 24 5c | 62 75 6c 6c 65 74 24 7d |\item{$\|bullet$}|
|00001290| 20 0a 4c 45 44 41 20 70 | 72 6f 76 69 64 65 73 20 | .LEDA p|rovides |
|000012a0| 61 20 73 69 7a 61 62 6c | 65 20 63 6f 6c 6c 65 63 |a sizabl|e collec|
|000012b0| 74 69 6f 6e 20 6f 66 20 | 0a 64 61 74 61 20 74 79 |tion of |.data ty|
|000012c0| 70 65 73 20 61 6e 64 20 | 61 6c 67 6f 72 69 74 68 |pes and |algorith|
|000012d0| 6d 73 20 69 6e 20 61 20 | 66 6f 72 6d 20 77 68 69 |ms in a |form whi|
|000012e0| 63 68 20 61 6c 6c 6f 77 | 73 20 74 68 65 6d 20 74 |ch allow|s them t|
|000012f0| 6f 20 62 65 0a 75 73 65 | 64 20 62 79 20 6e 6f 6e |o be.use|d by non|
|00001300| 2d 65 78 70 65 72 74 73 | 2e 20 49 6e 20 74 68 65 |-experts|. In the|
|00001310| 20 66 69 72 73 74 20 76 | 65 72 73 69 6f 6e 20 6f | first v|ersion o|
|00001320| 66 20 4c 45 44 41 2c 20 | 77 68 69 63 68 20 68 61 |f LEDA, |which ha|
|00001330| 73 0a 62 65 65 6e 20 63 | 6f 6d 70 6c 65 74 65 64 |s.been c|ompleted|
|00001340| 20 69 6e 20 74 68 65 20 | 73 70 72 69 6e 67 20 6f | in the |spring o|
|00001350| 66 20 31 39 39 30 2c 20 | 74 68 69 73 20 63 6f 6c |f 1990, |this col|
|00001360| 6c 65 63 74 69 6f 6e 20 | 0a 69 6e 63 6c 75 64 65 |lection |.include|
|00001370| 64 20 6d 6f 73 74 20 6f | 66 20 74 68 65 20 64 61 |d most o|f the da|
|00001380| 74 61 20 74 79 70 65 73 | 20 61 6e 64 20 61 6c 67 |ta types| and alg|
|00001390| 6f 72 69 74 68 6d 73 20 | 64 65 73 63 72 69 62 65 |orithms |describe|
|000013a0| 64 20 69 6e 0a 74 68 65 | 20 74 65 78 74 20 62 6f |d in.the| text bo|
|000013b0| 6f 6b 73 20 6f 66 20 74 | 68 65 20 61 72 65 61 28 |oks of t|he area(|
|000013c0| 65 2e 67 2e 20 5b 41 48 | 55 38 33 5d 2c 5b 4d 38 |e.g. [AH|U83],[M8|
|000013d0| 34 5d 2c 5b 54 38 33 5d | 2c 5b 43 4c 52 39 30 5d |4],[T83]|,[CLR90]|
|000013e0| 29 2c 0a 69 2e 65 2e 2c | 20 73 74 61 63 6b 73 2c |),.i.e.,| stacks,|
|000013f0| 20 71 75 65 75 65 73 2c | 20 6c 69 73 74 73 2c 20 | queues,| lists, |
|00001400| 73 65 74 73 2c 20 64 69 | 63 74 69 6f 6e 61 72 69 |sets, di|ctionari|
|00001410| 65 73 2c 20 6f 72 64 65 | 72 65 64 0a 73 65 71 75 |es, orde|red.sequ|
|00001420| 65 6e 63 65 73 2c 20 70 | 61 72 74 69 74 69 6f 6e |ences, p|artition|
|00001430| 73 2c 20 70 72 69 6f 72 | 69 74 79 20 71 75 65 75 |s, prior|ity queu|
|00001440| 65 73 2c 20 64 69 72 65 | 63 74 65 64 2c 20 75 6e |es, dire|cted, un|
|00001450| 64 69 72 65 63 74 65 64 | 2c 20 61 6e 64 0a 70 6c |directed|, and.pl|
|00001460| 61 6e 61 72 20 67 72 61 | 70 68 73 2c 20 6c 69 6e |anar gra|phs, lin|
|00001470| 65 73 2c 20 70 6f 69 6e | 74 73 2c 20 70 6c 61 6e |es, poin|ts, plan|
|00001480| 65 73 20 61 6e 64 20 62 | 61 73 69 63 20 61 6c 67 |es and b|asic alg|
|00001490| 6f 72 69 74 68 6d 73 20 | 0a 69 6e 20 67 72 61 70 |orithms |.in grap|
|000014a0| 68 20 61 6e 64 20 6e 65 | 74 77 6f 72 6b 20 74 68 |h and ne|twork th|
|000014b0| 65 6f 72 79 20 61 6e 64 | 0a 63 6f 6d 70 75 74 61 |eory and|.computa|
|000014c0| 74 69 6f 6e 61 6c 20 67 | 65 6f 6d 65 74 72 79 2e |tional g|eometry.|
|000014d0| 20 57 65 20 72 65 66 65 | 72 20 74 68 65 20 72 65 | We refe|r the re|
|000014e0| 61 64 65 72 20 74 6f 20 | 74 68 65 20 4c 45 44 41 |ader to |the LEDA|
|000014f0| 20 6d 61 6e 75 61 6c 28 | 5b 4e 39 30 5d 29 20 0a | manual(|[N90]) .|
|00001500| 66 6f 72 20 74 68 65 20 | 6c 69 73 74 20 6f 66 20 |for the |list of |
|00001510| 64 61 74 61 20 74 79 70 | 65 73 20 61 6e 64 20 61 |data typ|es and a|
|00001520| 6c 67 6f 72 69 74 68 6d | 73 20 61 76 61 69 6c 61 |lgorithm|s availa|
|00001530| 62 6c 65 20 61 73 20 6f | 66 20 46 61 6c 6c 20 31 |ble as o|f Fall 1|
|00001540| 39 39 30 2e 20 0a 0a 5c | 69 74 65 6d 20 7b 24 5c |990. ..\|item {$\|
|00001550| 62 75 6c 6c 65 74 24 7d | 0a 4c 45 44 41 20 67 69 |bullet$}|.LEDA gi|
|00001560| 76 65 73 20 61 20 70 72 | 65 63 69 73 65 20 61 6e |ves a pr|ecise an|
|00001570| 64 20 72 65 61 64 61 62 | 6c 65 20 73 70 65 63 69 |d readab|le speci|
|00001580| 66 69 63 61 74 69 6f 6e | 0a 66 6f 72 20 65 61 63 |fication|.for eac|
|00001590| 68 20 6f 66 20 74 68 65 | 20 64 61 74 61 20 74 79 |h of the| data ty|
|000015a0| 70 65 73 20 61 6e 64 20 | 61 6c 67 6f 72 69 74 68 |pes and |algorith|
|000015b0| 6d 73 20 6d 65 6e 74 69 | 6f 6e 65 64 20 61 62 6f |ms menti|oned abo|
|000015c0| 76 65 2e 0a 54 68 65 20 | 73 70 65 63 69 66 69 63 |ve..The |specific|
|000015d0| 61 74 69 6f 6e 73 20 61 | 72 65 20 73 68 6f 72 74 |ations a|re short|
|000015e0| 20 28 74 79 70 69 63 61 | 6c 6c 79 2c 20 6e 6f 74 | (typica|lly, not|
|000015f0| 20 6d 6f 72 65 20 74 68 | 61 6e 20 61 20 70 61 67 | more th|an a pag|
|00001600| 65 29 2c 0a 67 65 6e 65 | 72 61 6c 20 28 73 6f 20 |e),.gene|ral (so |
|00001610| 61 73 20 74 6f 20 61 6c | 6c 6f 77 20 73 65 76 65 |as to al|low seve|
|00001620| 72 61 6c 20 69 6d 70 6c | 65 6d 65 6e 74 61 74 69 |ral impl|ementati|
|00001630| 6f 6e 73 29 2c 20 61 6e | 64 20 61 62 73 74 72 61 |ons), an|d abstra|
|00001640| 63 74 20 28 73 6f 0a 61 | 73 20 74 6f 20 68 69 64 |ct (so.a|s to hid|
|00001650| 65 20 61 6c 6c 20 64 65 | 74 61 69 6c 73 20 6f 66 |e all de|tails of|
|00001660| 20 74 68 65 20 69 6d 70 | 6c 65 6d 65 6e 74 61 74 | the imp|lementat|
|00001670| 69 6f 6e 29 2e 20 0a 46 | 6f 72 20 6d 61 6e 79 20 |ion). .F|or many |
|00001680| 65 66 66 69 63 69 65 6e | 74 20 64 61 74 61 20 73 |efficien|t data s|
|00001690| 74 72 75 63 74 75 72 65 | 73 20 61 63 63 65 73 73 |tructure|s access|
|000016a0| 20 62 79 20 70 6f 73 69 | 74 69 6f 6e 20 69 73 20 | by posi|tion is |
|000016b0| 69 6d 70 6f 72 74 61 6e | 74 2e 20 0a 49 6e 20 4c |importan|t. .In L|
|000016c0| 45 44 41 2c 20 77 65 20 | 75 73 65 20 61 6e 20 69 |EDA, we |use an i|
|000016d0| 74 65 6d 20 63 6f 6e 63 | 65 70 74 20 74 6f 20 63 |tem conc|ept to c|
|000016e0| 61 73 74 20 70 6f 73 69 | 74 69 6f 6e 73 20 69 6e |ast posi|tions in|
|000016f0| 74 6f 20 61 6e 20 61 62 | 73 74 72 61 63 74 20 0a |to an ab|stract .|
|00001700| 66 6f 72 6d 2e 20 57 65 | 20 69 6e 74 72 6f 64 75 |form. We| introdu|
|00001710| 63 65 20 74 68 69 73 20 | 63 6f 6e 63 65 70 74 20 |ce this |concept |
|00001720| 69 6e 20 73 65 63 74 69 | 6f 6e 20 49 49 20 61 6e |in secti|on II an|
|00001730| 64 20 64 65 6d 6f 6e 73 | 74 72 61 74 65 20 0a 69 |d demons|trate .i|
|00001740| 74 73 20 75 73 65 66 75 | 6c 6e 65 73 73 20 6f 6e |ts usefu|lness on|
|00001750| 20 73 65 76 65 72 61 6c | 20 65 78 61 6d 70 6c 65 | several| example|
|00001760| 73 2e 20 57 65 20 6d 65 | 6e 74 69 6f 6e 20 74 68 |s. We me|ntion th|
|00001770| 61 74 20 6d 6f 73 74 20 | 6f 66 20 0a 74 68 65 20 |at most |of .the |
|00001780| 73 70 65 63 69 66 69 63 | 61 74 69 6f 6e 73 20 67 |specific|ations g|
|00001790| 69 76 65 6e 20 69 6e 20 | 74 68 65 20 4c 45 44 41 |iven in |the LEDA|
|000017a0| 20 6d 61 6e 75 61 6c 20 | 75 73 65 20 74 68 69 73 | manual |use this|
|000017b0| 20 63 6f 6e 63 65 70 74 | 2c 20 0a 69 2e 65 2e 2c | concept|, .i.e.,|
|000017c0| 20 74 68 65 20 63 6f 6e | 63 65 70 74 20 69 73 20 | the con|cept is |
|000017d0| 61 64 65 71 75 61 74 65 | 20 66 6f 72 20 74 68 65 |adequate| for the|
|000017e0| 20 64 65 73 63 72 69 70 | 74 69 6f 6e 20 6f 66 20 | descrip|tion of |
|000017f0| 6d 61 6e 79 20 64 61 74 | 61 20 74 79 70 65 73 2e |many dat|a types.|
|00001800| 0a 0a 5c 69 74 65 6d 20 | 7b 24 5c 62 75 6c 6c 65 |..\item |{$\bulle|
|00001810| 74 24 7d 0a 4c 45 44 41 | 20 63 6f 6e 74 61 69 6e |t$}.LEDA| contain|
|00001820| 73 20 65 66 66 69 63 69 | 65 6e 74 20 69 6d 70 6c |s effici|ent impl|
|00001830| 65 6d 65 6e 74 61 74 69 | 6f 6e 73 20 66 6f 72 20 |ementati|ons for |
|00001840| 65 61 63 68 20 6f 66 20 | 74 68 65 0a 64 61 74 61 |each of |the.data|
|00001850| 20 74 79 70 65 73 2c 20 | 65 2e 67 2e 2c 20 46 69 | types, |e.g., Fi|
|00001860| 62 6f 6e 61 63 63 69 20 | 68 65 61 70 73 20 61 6e |bonacci |heaps an|
|00001870| 64 20 72 65 64 69 73 74 | 72 69 62 75 74 69 76 65 |d redist|ributive|
|00001880| 20 68 65 61 70 73 20 66 | 6f 72 0a 70 72 69 6f 72 | heaps f|or.prior|
|00001890| 69 74 79 20 71 75 65 75 | 65 73 2c 20 72 65 64 2d |ity queu|es, red-|
|000018a0| 62 6c 61 63 6b 20 74 72 | 65 65 73 20 61 6e 64 20 |black tr|ees and |
|000018b0| 64 79 6e 61 6d 69 63 20 | 70 65 72 66 65 63 74 20 |dynamic |perfect |
|000018c0| 68 61 73 68 69 6e 67 20 | 66 6f 72 0a 64 69 63 74 |hashing |for.dict|
|000018d0| 69 6f 6e 61 72 69 65 73 | 2c 20 2e 2e 2e 0a 0a 5c |ionaries|, .....\|
|000018e0| 69 74 65 6d 20 7b 24 5c | 62 75 6c 6c 65 74 24 7d |item {$\|bullet$}|
|000018f0| 0a 4c 45 44 41 20 63 6f | 6e 74 61 69 6e 73 20 61 |.LEDA co|ntains a|
|00001900| 20 63 6f 6d 66 6f 72 74 | 61 62 6c 65 20 64 61 74 | comfort|able dat|
|00001910| 61 20 74 79 70 65 20 67 | 72 61 70 68 2e 20 0a 49 |a type g|raph. .I|
|00001920| 74 20 6f 66 66 65 72 73 | 20 74 68 65 20 73 74 61 |t offers| the sta|
|00001930| 6e 64 61 72 64 20 69 74 | 65 72 61 74 69 6f 6e 73 |ndard it|erations|
|00001940| 20 73 75 63 68 20 61 73 | 20 60 60 66 6f 72 20 61 | such as| ``for a|
|00001950| 6c 6c 20 6e 6f 64 65 73 | 20 24 76 24 0a 6f 66 20 |ll nodes| $v$.of |
|00001960| 61 20 67 72 61 70 68 20 | 24 47 24 20 64 6f 27 27 |a graph |$G$ do''|
|00001970| 20 28 77 72 69 74 74 65 | 6e 20 24 66 6f 72 61 6c | (writte|n $foral|
|00001980| 6c 5c 5f 6e 6f 64 65 73 | 28 76 2c 47 29 24 29 20 |l\_nodes|(v,G)$) |
|00001990| 6f 72 20 60 60 66 6f 72 | 20 61 6c 6c 0a 6e 65 69 |or ``for| all.nei|
|000019a0| 67 68 62 6f 72 73 20 24 | 77 24 20 6f 66 20 24 76 |ghbors $|w$ of $v|
|000019b0| 24 20 64 6f 27 27 20 28 | 77 72 69 74 74 65 6e 20 |$ do'' (|written |
|000019c0| 24 66 6f 72 61 6c 6c 5c | 5f 61 64 6a 5c 5f 6e 6f |$forall\|_adj\_no|
|000019d0| 64 65 73 28 77 2c 76 29 | 24 29 2c 20 69 74 0a 61 |des(w,v)|$), it.a|
|000019e0| 6c 6c 6f 77 73 20 74 6f | 20 61 64 64 20 61 6e 64 |llows to| add and|
|000019f0| 20 64 65 6c 65 74 65 20 | 76 65 72 74 69 63 65 73 | delete |vertices|
|00001a00| 20 61 6e 64 20 65 64 67 | 65 73 20 61 6e 64 20 69 | and edg|es and i|
|00001a10| 74 20 6f 66 66 65 72 73 | 0a 61 72 72 61 79 73 20 |t offers|.arrays |
|00001a20| 61 6e 64 20 6d 61 74 72 | 69 63 65 73 20 69 6e 64 |and matr|ices ind|
|00001a30| 65 78 65 64 20 62 79 20 | 6e 6f 64 65 73 20 61 6e |exed by |nodes an|
|00001a40| 64 20 65 64 67 65 73 2c | 2e 2e 2e 2c 20 63 66 2e |d edges,|..., cf.|
|00001a50| 20 73 65 63 74 69 6f 6e | 7e 49 49 49 20 0a 66 6f | section|~III .fo|
|00001a60| 72 20 64 65 74 61 69 6c | 73 2e 20 54 68 65 20 64 |r detail|s. The d|
|00001a70| 61 74 61 20 74 79 70 65 | 20 67 72 61 70 68 20 61 |ata type| graph a|
|00001a80| 6c 6c 6f 77 73 20 74 6f | 20 77 72 69 74 65 20 70 |llows to| write p|
|00001a90| 72 6f 67 72 61 6d 73 20 | 66 6f 72 20 67 72 61 70 |rograms |for grap|
|00001aa0| 68 20 70 72 6f 62 6c 65 | 6d 73 0a 69 6e 20 61 20 |h proble|ms.in a |
|00001ab0| 66 6f 72 6d 20 63 6c 6f | 73 65 20 74 6f 20 74 68 |form clo|se to th|
|00001ac0| 65 20 74 79 70 69 63 61 | 6c 20 74 65 78 74 20 62 |e typica|l text b|
|00001ad0| 6f 6f 6b 20 70 72 65 73 | 65 6e 74 61 74 69 6f 6e |ook pres|entation|
|00001ae0| 2e 20 57 65 20 65 6d 70 | 68 61 73 69 7a 65 0a 74 |. We emp|hasize.t|
|00001af0| 68 61 74 20 61 6c 6c 20 | 65 78 61 6d 70 6c 65 73 |hat all |examples|
|00001b00| 20 67 69 76 65 6e 20 69 | 6e 20 74 68 69 73 20 70 | given i|n this p|
|00001b10| 61 70 65 72 20 73 68 6f | 77 20 65 78 65 63 75 74 |aper sho|w execut|
|00001b20| 61 62 6c 65 20 63 6f 64 | 65 2e 20 0a 41 20 6c 6f |able cod|e. .A lo|
|00001b30| 6e 67 20 74 65 72 6d 20 | 67 6f 61 6c 0a 69 73 20 |ng term |goal.is |
|00001b40| 74 68 65 20 65 71 75 61 | 74 69 6f 6e 20 60 60 41 |the equa|tion ``A|
|00001b50| 6c 67 6f 72 69 74 68 6d | 20 2b 20 4c 45 44 41 20 |lgorithm| + LEDA |
|00001b60| 3d 20 70 72 6f 67 72 61 | 6d 27 27 2e 0a 0a 5c 65 |= progra|m''...\e|
|00001b70| 6e 64 69 74 65 6d 0a 0a | 49 6e 20 74 68 69 73 20 |nditem..|In this |
|00001b80| 70 61 70 65 72 20 77 65 | 20 64 65 73 63 72 69 62 |paper we| describ|
|00001b90| 65 20 74 68 65 20 73 74 | 61 74 75 73 20 6f 66 20 |e the st|atus of |
|00001ba0| 74 68 65 20 70 72 6f 6a | 65 63 74 2e 0a 57 65 20 |the proj|ect..We |
|00001bb0| 68 6f 70 65 20 74 68 61 | 74 20 4c 45 44 41 20 77 |hope tha|t LEDA w|
|00001bc0| 69 6c 6c 20 6e 61 72 72 | 6f 77 0a 74 68 65 20 67 |ill narr|ow.the g|
|00001bd0| 61 70 20 62 65 74 77 65 | 65 6e 20 61 6c 67 6f 72 |ap betwe|en algor|
|00001be0| 69 74 68 6d 73 20 72 65 | 73 65 61 72 63 68 2c 20 |ithms re|search, |
|00001bf0| 74 65 61 63 68 69 6e 67 | 2c 20 61 6e 64 0a 69 6d |teaching|, and.im|
|00001c00| 70 6c 65 6d 65 6e 74 61 | 74 69 6f 6e 2e 20 4f 74 |plementa|tion. Ot|
|00001c10| 68 65 72 20 70 72 6f 6a | 65 63 74 73 20 77 69 74 |her proj|ects wit|
|00001c20| 68 20 73 69 6d 69 6c 61 | 72 20 67 6f 61 6c 73 20 |h simila|r goals |
|00001c30| 61 72 65 20 64 65 73 63 | 72 69 62 65 64 0a 69 6e |are desc|ribed.in|
|00001c40| 20 28 5b 42 38 37 5d 2c | 5b 4c 69 6e 38 39 5d 2c | ([B87],|[Lin89],|
|00001c50| 5b 53 6f 38 39 5d 29 3b | 20 68 6f 77 65 76 65 72 |[So89]);| however|
|00001c60| 2c 20 61 6c 6c 20 6f 66 | 20 74 68 65 73 65 20 70 |, all of| these p|
|00001c70| 72 6f 6a 65 63 74 73 20 | 73 65 74 74 6c 65 20 66 |rojects |settle f|
|00001c80| 6f 72 20 61 0a 63 6f 6e | 73 69 64 65 72 61 62 6c |or a.con|siderabl|
|00001c90| 79 20 73 6d 61 6c 6c 65 | 72 20 63 6f 6c 6c 65 63 |y smalle|r collec|
|00001ca0| 74 69 6f 6e 20 6f 66 20 | 64 61 74 61 20 74 79 70 |tion of |data typ|
|00001cb0| 65 73 20 61 6e 64 20 61 | 6c 67 6f 72 69 74 68 6d |es and a|lgorithm|
|00001cc0| 73 20 74 68 61 6e 0a 4c | 45 44 41 2e 0a 4f 75 72 |s than.L|EDA..Our|
|00001cd0| 20 61 70 70 72 6f 61 63 | 68 20 74 6f 20 72 65 61 | approac|h to rea|
|00001ce0| 63 68 20 74 68 65 20 67 | 6f 61 6c 73 20 6f 66 20 |ch the g|oals of |
|00001cf0| 4c 45 44 41 20 69 73 20 | 73 74 61 6e 64 61 72 64 |LEDA is |standard|
|00001d00| 2e 20 53 69 6d 69 6c 61 | 72 6c 79 0a 74 6f 20 74 |. Simila|rly.to t|
|00001d10| 68 65 20 6f 74 68 65 72 | 20 70 72 6f 6a 65 63 74 |he other| project|
|00001d20| 73 20 77 65 20 65 6d 70 | 6c 6f 79 0a 0a 5c 62 65 |s we emp|loy..\be|
|00001d30| 67 69 6e 69 74 65 6d 0a | 5c 69 74 65 6d 7b 31 2e |ginitem.|\item{1.|
|00001d40| 7d 20 61 20 73 74 72 69 | 63 74 20 73 65 70 61 72 |} a stri|ct separ|
|00001d50| 61 74 69 6f 6e 20 62 65 | 74 77 65 65 6e 20 61 62 |ation be|tween ab|
|00001d60| 73 74 72 61 63 74 20 64 | 61 74 61 20 74 79 70 65 |stract d|ata type|
|00001d70| 73 20 61 6e 64 20 74 68 | 65 20 0a 63 6f 6e 63 72 |s and th|e .concr|
|00001d80| 65 74 65 20 64 61 74 61 | 20 73 74 72 75 63 74 75 |ete data| structu|
|00001d90| 72 65 73 20 75 73 65 64 | 20 74 6f 20 69 6d 70 6c |res used| to impl|
|00001da0| 65 6d 65 6e 74 20 74 68 | 65 6d 2c 0a 5c 69 74 65 |ement th|em,.\ite|
|00001db0| 6d 7b 32 2e 7d 20 70 61 | 72 61 6d 65 74 65 72 69 |m{2.} pa|rameteri|
|00001dc0| 7a 65 64 20 64 61 74 61 | 20 74 79 70 65 73 2c 20 |zed data| types, |
|00001dd0| 61 6e 64 20 0a 5c 69 74 | 65 6d 7b 33 2e 7d 20 6f |and .\it|em{3.} o|
|00001de0| 62 6a 65 63 74 20 6f 72 | 69 65 6e 74 65 64 20 70 |bject or|iented p|
|00001df0| 72 6f 67 72 61 6d 6d 69 | 6e 67 2e 0a 5c 65 6e 64 |rogrammi|ng..\end|
|00001e00| 69 74 65 6d 0a 0a 0a 54 | 68 65 20 69 6d 70 6c 65 |item...T|he imple|
|00001e10| 6d 65 6e 74 61 74 69 6f | 6e 20 6c 61 6e 67 75 61 |mentatio|n langua|
|00001e20| 67 65 20 6f 66 20 4c 45 | 44 41 20 69 73 20 5c 43 |ge of LE|DA is \C|
|00001e30| 43 2e 20 57 65 20 68 61 | 76 65 20 63 68 6f 73 65 |C. We ha|ve chose|
|00001e40| 6e 20 5c 43 43 0a 62 65 | 63 61 75 73 65 20 6f 66 |n \CC.be|cause of|
|00001e50| 20 69 74 73 20 66 6c 65 | 78 69 62 69 6c 69 74 79 | its fle|xibility|
|00001e60| 20 61 6e 64 20 61 76 61 | 69 6c 61 62 69 6c 69 74 | and ava|ilabilit|
|00001e70| 79 2e 20 41 6c 6c 20 64 | 61 74 61 20 74 79 70 65 |y. All d|ata type|
|00001e80| 73 0a 61 6e 64 20 61 6c | 67 6f 72 69 74 68 6d 73 |s.and al|gorithms|
|00001e90| 20 61 72 65 20 70 72 65 | 63 6f 6d 70 69 6c 65 64 | are pre|compiled|
|00001ea0| 20 6d 6f 64 75 6c 65 73 | 20 77 68 69 63 68 20 63 | modules| which c|
|00001eb0| 61 6e 20 62 65 20 6c 69 | 6e 6b 65 64 0a 77 69 74 |an be li|nked.wit|
|00001ec0| 68 20 61 70 70 6c 69 63 | 61 74 69 6f 6e 20 70 72 |h applic|ation pr|
|00001ed0| 6f 67 72 61 6d 73 2e 20 | 50 6f 6c 79 6d 6f 72 70 |ograms. |Polymorp|
|00001ee0| 68 69 63 20 74 79 70 65 | 73 20 61 72 65 20 69 6d |hic type|s are im|
|00001ef0| 70 6c 65 6d 65 6e 74 65 | 64 0a 61 73 20 64 65 73 |plemente|d.as des|
|00001f00| 63 72 69 62 65 64 20 69 | 6e 20 28 5b 53 74 38 36 |cribed i|n ([St86|
|00001f10| 5d 29 2e 0a 0a 54 68 69 | 73 20 70 61 70 65 72 20 |])...Thi|s paper |
|00001f20| 69 73 20 6f 72 67 61 6e | 69 7a 65 64 20 61 73 20 |is organ|ized as |
|00001f30| 66 6f 6c 6c 6f 77 73 2e | 0a 49 6e 20 73 65 63 74 |follows.|.In sect|
|00001f40| 69 6f 6e 20 49 49 20 77 | 65 20 64 69 73 63 75 73 |ion II w|e discus|
|00001f50| 73 20 64 61 74 61 20 74 | 79 70 65 73 20 61 6e 64 |s data t|ypes and|
|00001f60| 20 64 61 74 61 20 73 74 | 72 75 63 74 75 72 65 73 | data st|ructures|
|00001f70| 2c 20 61 6e 64 20 69 6e | 0a 73 65 63 74 69 6f 6e |, and in|.section|
|00001f80| 20 49 49 49 20 74 68 65 | 20 64 61 74 61 20 74 79 | III the| data ty|
|00001f90| 70 65 20 67 72 61 70 68 | 20 61 6e 64 20 74 68 65 |pe graph| and the|
|00001fa0| 20 69 6e 74 65 72 61 63 | 74 69 6f 6e 20 6f 66 20 | interac|tion of |
|00001fb0| 67 72 61 70 68 73 20 0a | 61 6e 64 20 6f 74 68 65 |graphs .|and othe|
|00001fc0| 72 20 64 61 74 61 20 74 | 79 70 65 73 2e 20 20 49 |r data t|ypes. I|
|00001fd0| 6e 20 73 65 63 74 69 6f | 6e 20 49 56 20 77 65 20 |n sectio|n IV we |
|00001fe0| 62 72 69 65 66 6c 79 20 | 63 6f 6d 6d 65 6e 74 20 |briefly |comment |
|00001ff0| 6f 6e 20 74 68 65 20 0a | 65 78 74 65 6e 64 69 62 |on the .|extendib|
|00002000| 69 6c 69 74 79 20 61 6e | 64 20 69 6e 20 73 65 63 |ility an|d in sec|
|00002010| 74 69 6f 6e 20 56 20 6f | 6e 20 74 68 65 20 69 6e |tion V o|n the in|
|00002020| 74 65 72 6e 61 6c 20 73 | 74 72 75 63 74 75 72 65 |ternal s|tructure|
|00002030| 20 6f 66 20 4c 45 44 41 | 2e 20 0a 53 65 63 74 69 | of LEDA|. .Secti|
|00002040| 6f 6e 20 56 49 20 67 69 | 76 65 73 20 61 20 73 68 |on VI gi|ves a sh|
|00002050| 6f 72 74 20 73 75 6d 6d | 61 72 79 2e 0a 0a 54 68 |ort summ|ary...Th|
|00002060| 65 20 64 65 73 69 67 6e | 20 6f 66 20 4c 45 44 41 |e design| of LEDA|
|00002070| 20 69 73 20 6a 6f 69 6e | 74 20 77 6f 72 6b 20 62 | is join|t work b|
|00002080| 79 20 74 68 65 20 74 77 | 6f 20 61 75 74 68 6f 72 |y the tw|o author|
|00002090| 73 2c 20 74 68 65 20 69 | 6d 70 6c 65 6d 65 6e 74 |s, the i|mplement|
|000020a0| 61 74 69 6f 6e 0a 77 61 | 73 20 6d 6f 73 74 6c 79 |ation.wa|s mostly|
|000020b0| 20 64 6f 6e 65 20 62 79 | 20 74 68 65 20 73 65 63 | done by| the sec|
|000020c0| 6f 6e 64 20 61 75 74 68 | 6f 72 2e 20 54 68 65 20 |ond auth|or. The |
|000020d0| 6c 69 62 72 61 72 79 20 | 63 61 6e 20 62 65 20 75 |library |can be u|
|000020e0| 73 65 64 20 75 6e 64 65 | 72 20 55 4e 49 58 0a 77 |sed unde|r UNIX.w|
|000020f0| 69 74 68 20 74 68 65 20 | 5c 43 43 20 63 6f 6d 70 |ith the |\CC comp|
|00002100| 69 6c 65 72 73 20 41 54 | 5c 26 54 20 63 66 72 6f |ilers AT|\&T cfro|
|00002110| 6e 74 20 32 2e 30 2c 20 | 63 66 72 6f 6e 74 20 32 |nt 2.0, |cfront 2|
|00002120| 2e 31 20 61 6e 64 20 47 | 4e 55 20 5c 67 67 20 28 |.1 and G|NU \gg (|
|00002130| 76 65 72 73 69 6f 6e 20 | 31 2e 33 37 29 2e 20 49 |version |1.37). I|
|00002140| 74 20 69 73 20 61 76 61 | 69 6c 61 62 6c 65 20 66 |t is ava|ilable f|
|00002150| 72 6f 6d 20 74 68 65 20 | 61 75 74 68 6f 72 73 20 |rom the |authors |
|00002160| 66 6f 72 20 61 20 68 61 | 6e 64 6c 69 6e 67 20 63 |for a ha|ndling c|
|00002170| 68 61 72 67 65 20 6f 66 | 20 44 4d 20 31 30 30 2e |harge of| DM 100.|
|00002180| 0a 0a 0a 5c 62 69 67 73 | 6b 69 70 0a 5c 62 69 67 |...\bigs|kip.\big|
|00002190| 73 6b 69 70 0a 7b 5c 6d | 61 67 6f 6e 65 62 66 20 |skip.{\m|agonebf |
|000021a0| 49 49 2e 20 44 61 74 61 | 20 54 79 70 65 73 20 61 |II. Data| Types a|
|000021b0| 6e 64 20 49 74 65 6d 73 | 7d 0a 0a 49 6e 20 74 68 |nd Items|}..In th|
|000021c0| 69 73 20 73 65 63 74 69 | 6f 6e 20 77 65 20 64 69 |is secti|on we di|
|000021d0| 73 63 75 73 73 20 74 68 | 65 20 73 70 65 63 69 66 |scuss th|e specif|
|000021e0| 69 63 61 74 69 6f 6e 20 | 6f 66 20 64 61 74 61 20 |ication |of data |
|000021f0| 74 79 70 65 73 20 69 6e | 20 0a 4c 45 44 41 20 6f |types in| .LEDA o|
|00002200| 6e 20 74 68 65 20 62 61 | 73 69 73 20 6f 66 20 74 |n the ba|sis of t|
|00002210| 68 72 65 65 20 65 78 61 | 6d 70 6c 65 73 3a 20 64 |hree exa|mples: d|
|00002220| 69 63 74 69 6f 6e 61 72 | 69 65 73 2c 20 70 72 69 |ictionar|ies, pri|
|00002230| 6f 72 69 74 79 0a 71 75 | 65 75 65 73 2c 20 61 6e |ority.qu|eues, an|
|00002240| 64 20 70 61 72 74 69 74 | 69 6f 6e 73 2e 20 0a 0a |d partit|ions. ..|
|00002250| 0a 5c 62 69 67 73 6b 69 | 70 0a 7b 5c 6d 61 67 6f |.\bigski|p.{\mago|
|00002260| 6e 65 20 45 78 61 6d 70 | 6c 65 20 31 3a 20 44 69 |ne Examp|le 1: Di|
|00002270| 63 74 69 6f 6e 61 72 69 | 65 73 7d 0a 0a 41 20 70 |ctionari|es}..A p|
|00002280| 6f 70 75 6c 61 72 20 73 | 70 65 63 69 66 69 63 61 |opular s|pecifica|
|00002290| 74 69 6f 6e 20 6f 66 20 | 64 69 63 74 69 6f 6e 61 |tion of |dictiona|
|000022a0| 72 69 65 73 20 64 65 66 | 69 6e 65 73 20 61 20 0a |ries def|ines a .|
|000022b0| 64 69 63 74 69 6f 6e 61 | 72 79 20 61 73 20 61 20 |dictiona|ry as a |
|000022c0| 70 61 72 74 69 61 6c 20 | 66 75 6e 63 74 69 6f 6e |partial |function|
|000022d0| 20 66 72 6f 6d 20 73 6f | 6d 65 20 74 79 70 65 20 | from so|me type |
|000022e0| 24 4b 24 20 74 6f 20 0a | 73 6f 6d 65 20 6f 74 68 |$K$ to .|some oth|
|000022f0| 65 72 20 74 79 70 65 20 | 24 49 24 2c 20 6f 72 20 |er type |$I$, or |
|00002300| 61 6c 74 65 72 6e 61 74 | 69 76 65 6c 79 2c 20 61 |alternat|ively, a|
|00002310| 73 20 61 0a 73 65 74 20 | 6f 66 20 70 61 69 72 73 |s a.set |of pairs|
|00002320| 20 66 72 6f 6d 20 24 4b | 5c 74 69 6d 65 73 20 49 | from $K|\times I|
|00002330| 24 2c 20 69 2e 65 2e 2c | 20 61 73 20 74 68 65 20 |$, i.e.,| as the |
|00002340| 67 72 61 70 68 20 6f 66 | 20 0a 74 68 65 20 66 75 |graph of| .the fu|
|00002350| 6e 63 74 69 6f 6e 2e 20 | 49 6e 20 61 6e 20 69 6d |nction. |In an im|
|00002360| 70 6c 65 6d 65 6e 74 61 | 74 69 6f 6e 20 65 61 63 |plementa|tion eac|
|00002370| 68 20 70 61 69 72 20 24 | 28 6b 2c 69 29 24 20 0a |h pair $|(k,i)$ .|
|00002380| 69 6e 20 74 68 65 20 64 | 69 63 74 69 6f 6e 61 72 |in the d|ictionar|
|00002390| 79 20 69 73 20 73 74 6f | 72 65 64 20 69 6e 20 73 |y is sto|red in s|
|000023a0| 6f 6d 65 20 6c 6f 63 61 | 74 69 6f 6e 0a 6f 66 20 |ome loca|tion.of |
|000023b0| 74 68 65 20 6d 65 6d 6f | 72 79 2e 20 45 66 66 69 |the memo|ry. Effi|
|000023c0| 63 69 65 6e 63 79 20 64 | 69 63 74 61 74 65 73 20 |ciency d|ictates |
|000023d0| 74 68 61 74 20 74 68 65 | 20 70 61 69 72 20 24 28 |that the| pair $(|
|000023e0| 6b 2c 69 29 24 20 63 61 | 6e 6e 6f 74 20 6f 6e 6c |k,i)$ ca|nnot onl|
|000023f0| 79 20 62 65 0a 61 63 63 | 65 73 73 65 64 20 74 68 |y be.acc|essed th|
|00002400| 72 6f 75 67 68 20 74 68 | 65 20 6b 65 79 20 24 6b |rough th|e key $k|
|00002410| 24 20 62 75 74 20 61 6c | 73 6f 20 74 68 72 6f 75 |$ but al|so throu|
|00002420| 67 68 20 74 68 65 20 6c | 6f 63 61 74 69 6f 6e 20 |gh the l|ocation |
|00002430| 77 68 65 72 65 20 69 74 | 0a 69 73 20 73 74 6f 72 |where it|.is stor|
|00002440| 65 64 2c 20 65 2e 67 2e | 2c 20 77 65 20 6d 69 67 |ed, e.g.|, we mig|
|00002450| 68 74 20 77 61 6e 74 20 | 74 6f 20 6c 6f 6f 6b 75 |ht want |to looku|
|00002460| 70 20 74 68 65 20 69 6e | 66 6f 72 6d 61 74 69 6f |p the in|formatio|
|00002470| 6e 20 24 69 24 20 61 73 | 73 6f 63 69 61 74 65 64 |n $i$ as|sociated|
|00002480| 20 0a 77 69 74 68 20 6b | 65 79 20 24 6b 24 20 28 | .with k|ey $k$ (|
|00002490| 74 68 69 73 20 69 6e 76 | 6f 6c 76 65 73 20 61 20 |this inv|olves a |
|000024a0| 73 65 61 72 63 68 20 69 | 6e 20 74 68 65 20 64 61 |search i|n the da|
|000024b0| 74 61 20 73 74 72 75 63 | 74 75 72 65 29 2c 20 74 |ta struc|ture), t|
|000024c0| 68 65 6e 20 63 6f 6d 70 | 75 74 65 20 0a 77 69 74 |hen comp|ute .wit|
|000024d0| 68 20 74 68 65 20 76 61 | 6c 75 65 20 24 69 24 20 |h the va|lue $i$ |
|000024e0| 61 20 6e 65 77 20 76 61 | 6c 75 65 20 24 69 5c 27 |a new va|lue $i\'|
|000024f0| 24 2c 20 61 6e 64 20 66 | 69 6e 61 6c 6c 79 20 61 |$, and f|inally a|
|00002500| 73 73 6f 63 69 61 74 65 | 20 74 68 65 20 6e 65 77 |ssociate| the new|
|00002510| 20 76 61 6c 75 65 20 0a | 77 69 74 68 20 24 6b 24 | value .|with $k$|
|00002520| 2e 20 20 54 68 69 73 20 | 65 69 74 68 65 72 20 69 |. This |either i|
|00002530| 6e 76 6f 6c 76 65 73 20 | 61 6e 6f 74 68 65 72 20 |nvolves |another |
|00002540| 73 65 61 72 63 68 20 69 | 6e 20 74 68 65 20 64 61 |search i|n the da|
|00002550| 74 61 20 73 74 72 75 63 | 74 75 72 65 20 6f 72 2c |ta struc|ture or,|
|00002560| 20 69 66 20 0a 74 68 65 | 20 6c 6f 6f 6b 75 70 20 | if .the| lookup |
|00002570| 72 65 74 75 72 6e 65 64 | 20 74 68 65 20 6c 6f 63 |returned| the loc|
|00002580| 61 74 69 6f 6e 20 77 68 | 65 72 65 20 74 68 65 20 |ation wh|ere the |
|00002590| 70 61 69 72 20 24 28 6b | 2c 69 29 24 20 69 73 20 |pair $(k|,i)$ is |
|000025a0| 73 74 6f 72 65 64 2c 20 | 63 61 6e 20 62 65 20 0a |stored, |can be .|
|000025b0| 64 6f 6e 65 20 62 79 20 | 64 69 72 65 63 74 20 61 |done by |direct a|
|000025c0| 63 63 65 73 73 2e 20 4f | 66 20 63 6f 75 72 73 65 |ccess. O|f course|
|000025d0| 2c 20 74 68 65 20 73 65 | 63 6f 6e 64 20 73 6f 6c |, the se|cond sol|
|000025e0| 75 74 69 6f 6e 20 69 73 | 20 6d 6f 72 65 20 65 66 |ution is| more ef|
|000025f0| 66 69 63 69 65 6e 74 20 | 61 6e 64 20 0a 77 65 20 |ficient |and .we |
|00002600| 74 68 65 72 65 66 6f 72 | 65 20 77 61 6e 74 65 64 |therefor|e wanted|
|00002610| 20 74 6f 20 70 72 6f 76 | 69 64 65 20 69 74 20 69 | to prov|ide it i|
|00002620| 6e 20 4c 45 44 41 2e 0a | 0a 49 6e 20 4c 45 44 41 |n LEDA..|.In LEDA|
|00002630| 2c 20 74 68 65 20 61 62 | 73 74 72 61 63 74 69 6f |, the ab|stractio|
|00002640| 6e 20 6f 66 20 61 20 70 | 6f 73 69 74 69 6f 6e 20 |n of a p|osition |
|00002650| 6f 72 20 6c 6f 63 61 74 | 69 6f 6e 20 69 73 20 63 |or locat|ion is c|
|00002660| 61 6c 6c 65 64 20 61 6e | 20 69 74 65 6d 2e 20 0a |alled an| item. .|
|00002670| 41 6e 20 69 74 65 6d 20 | 69 73 20 61 20 63 6f 6e |An item |is a con|
|00002680| 74 61 69 6e 65 72 20 77 | 68 69 63 68 20 63 61 6e |tainer w|hich can|
|00002690| 20 68 6f 6c 64 20 61 6e | 20 6f 62 6a 65 63 74 20 | hold an| object |
|000026a0| 72 65 6c 65 76 61 6e 74 | 20 66 6f 72 20 74 68 65 |relevant| for the|
|000026b0| 20 64 61 74 61 20 0a 74 | 79 70 65 2e 20 49 6e 20 | data .t|ype. In |
|000026c0| 74 68 65 20 63 61 73 65 | 20 6f 66 20 64 69 63 74 |the case| of dict|
|000026d0| 69 6f 6e 61 72 69 65 73 | 20 61 20 24 64 69 63 5c |ionaries| a $dic\|
|000026e0| 5f 69 74 65 6d 24 20 63 | 6f 6e 74 61 69 6e 73 20 |_item$ c|ontains |
|000026f0| 61 20 70 61 69 72 20 63 | 6f 6e 73 69 73 74 69 6e |a pair c|onsistin|
|00002700| 67 20 0a 6f 66 20 61 20 | 6b 65 79 20 61 6e 64 20 |g .of a |key and |
|00002710| 61 6e 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 2e 20 |an infor|mation. |
|00002720| 20 0a 41 6e 20 6f 62 6a | 65 63 74 20 6f 66 20 74 | .An obj|ect of t|
|00002730| 79 70 65 20 24 64 69 63 | 74 69 6f 6e 61 72 79 28 |ype $dic|tionary(|
|00002740| 4b 2c 49 29 24 2c 20 77 | 68 65 72 65 20 24 4b 24 |K,I)$, w|here $K$|
|00002750| 20 61 6e 64 20 24 49 24 | 20 61 72 65 20 74 79 70 | and $I$| are typ|
|00002760| 65 73 2c 20 69 73 20 0a | 74 68 75 73 20 64 65 66 |es, is .|thus def|
|00002770| 69 6e 65 64 20 61 73 20 | 61 20 63 6f 6c 6c 65 63 |ined as |a collec|
|00002780| 74 69 6f 6e 20 6f 66 20 | 69 74 65 6d 73 20 28 6f |tion of |items (o|
|00002790| 66 20 74 79 70 65 20 24 | 64 69 63 5c 5f 69 74 65 |f type $|dic\_ite|
|000027a0| 6d 24 29 20 77 68 65 72 | 65 20 65 61 63 68 20 69 |m$) wher|e each i|
|000027b0| 74 65 6d 20 0a 63 6f 6e | 74 61 69 6e 73 20 61 20 |tem .con|tains a |
|000027c0| 70 61 69 72 20 69 6e 20 | 24 4b 5c 74 69 6d 65 73 |pair in |$K\times|
|000027d0| 20 49 24 2e 20 57 65 20 | 75 73 65 20 24 3c 6b 2c | I$. We |use $<k,|
|000027e0| 69 3e 24 20 74 6f 20 64 | 65 6e 6f 74 65 20 61 6e |i>$ to d|enote an|
|000027f0| 20 69 74 65 6d 20 77 69 | 74 68 20 6b 65 79 20 0a | item wi|th key .|
|00002800| 24 6b 24 20 61 6e 64 20 | 69 6e 66 6f 72 6d 61 74 |$k$ and |informat|
|00002810| 69 6f 6e 20 24 69 24 20 | 61 6e 64 20 72 65 71 75 |ion $i$ |and requ|
|00002820| 69 72 65 20 74 68 61 74 | 20 66 6f 72 20 65 61 63 |ire that| for eac|
|00002830| 68 20 24 6b 5c 69 6e 20 | 4b 24 20 74 68 65 72 65 |h $k\in |K$ there|
|00002840| 20 69 73 20 61 74 20 6d | 6f 73 74 20 0a 6f 6e 65 | is at m|ost .one|
|00002850| 20 24 69 5c 69 6e 20 49 | 24 20 73 75 63 68 20 74 | $i\in I|$ such t|
|00002860| 68 61 74 20 24 3c 6b 2c | 69 3e 24 20 69 73 20 69 |hat $<k,|i>$ is i|
|00002870| 6e 20 74 68 65 20 64 69 | 63 74 69 6f 6e 61 72 79 |n the di|ctionary|
|00002880| 2e 20 0a 49 6e 20 6d 61 | 74 68 65 6d 61 74 69 63 |. .In ma|thematic|
|00002890| 61 6c 20 74 65 72 6d 73 | 20 74 68 69 73 20 64 65 |al terms| this de|
|000028a0| 66 69 6e 69 74 69 6f 6e | 20 6d 61 79 20 62 65 20 |finition| may be |
|000028b0| 72 65 70 68 72 61 73 65 | 64 20 61 73 20 66 6f 6c |rephrase|d as fol|
|000028c0| 6c 6f 77 73 3a 20 0a 41 | 20 64 69 63 74 69 6f 6e |lows: .A| diction|
|000028d0| 61 72 79 20 24 44 24 20 | 69 73 20 61 20 70 61 72 |ary $D$ |is a par|
|000028e0| 74 69 61 6c 20 66 75 6e | 63 74 69 6f 6e 20 66 72 |tial fun|ction fr|
|000028f0| 6f 6d 20 74 68 65 20 73 | 65 74 20 24 64 69 63 5c |om the s|et $dic\|
|00002900| 5f 69 74 65 6d 24 20 74 | 6f 20 74 68 65 20 0a 73 |_item$ t|o the .s|
|00002910| 65 74 20 24 4b 5c 74 69 | 6d 65 73 20 49 24 2e 20 |et $K\ti|mes I$. |
|00002920| 4d 6f 72 65 6f 76 65 72 | 2c 20 66 6f 72 20 65 61 |Moreover|, for ea|
|00002930| 63 68 20 24 6b 5c 69 6e | 20 4b 24 20 74 68 65 72 |ch $k\in| K$ ther|
|00002940| 65 20 69 73 20 61 74 20 | 6d 6f 73 74 20 6f 6e 65 |e is at |most one|
|00002950| 20 24 69 5c 69 6e 20 49 | 24 20 0a 73 75 63 68 20 | $i\in I|$ .such |
|00002960| 74 68 61 74 20 74 68 65 | 20 70 61 69 72 20 24 28 |that the| pair $(|
|00002970| 6b 2c 69 29 24 20 69 73 | 20 69 6e 20 74 68 65 20 |k,i)$ is| in the |
|00002980| 72 61 6e 67 65 20 6f 66 | 20 24 44 24 2e 0a 0a 54 |range of| $D$...T|
|00002990| 68 65 20 73 65 6d 61 6e | 74 69 63 73 20 6f 66 20 |he seman|tics of |
|000029a0| 74 68 65 20 6f 70 65 72 | 61 74 69 6f 6e 73 20 0a |the oper|ations .|
|000029b0| 5c 73 6d 61 6c 6c 73 6b | 69 70 0a 5c 2b 5c 71 75 |\smallsk|ip.\+\qu|
|000029c0| 61 64 5c 71 75 61 64 20 | 26 24 64 69 63 5c 5f 69 |ad\quad |&$dic\_i|
|000029d0| 74 65 6d 24 20 26 24 44 | 24 2e 6c 6f 6f 6b 75 70 |tem$ &$D|$.lookup|
|000029e0| 28 24 4b 5c 20 6b 24 29 | 5c 63 72 0a 5c 2b 20 20 |($K\ k$)|\cr.\+ |
|000029f0| 20 20 20 20 20 20 20 20 | 20 26 24 49 24 20 20 20 | | &$I$ |
|00002a00| 20 20 20 20 20 20 26 24 | 44 24 2e 69 6e 66 28 24 | &$|D$.inf($|
|00002a10| 64 69 63 5c 5f 69 74 65 | 6d 5c 20 69 74 24 29 5c |dic\_ite|m\ it$)\|
|00002a20| 63 72 0a 5c 2b 20 20 20 | 20 20 20 20 20 20 20 20 |cr.\+ | |
|00002a30| 26 24 76 6f 69 64 24 20 | 20 20 20 20 20 26 24 44 |&$void$ | &$D|
|00002a40| 24 2e 63 68 61 6e 67 65 | 5c 5f 69 6e 66 28 24 64 |$.change|\_inf($d|
|00002a50| 69 63 5c 5f 69 74 65 6d | 5c 20 69 74 2c 5c 20 49 |ic\_item|\ it,\ I|
|00002a60| 5c 20 69 5c 27 24 29 5c | 63 72 0a 69 73 20 6e 6f |\ i\'$)\|cr.is no|
|00002a70| 77 20 61 73 20 66 6f 6c | 6c 6f 77 73 3a 0a 24 44 |w as fol|lows:.$D|
|00002a80| 24 2e 6c 6f 6f 6b 75 70 | 28 24 6b 24 29 20 74 61 |$.lookup|($k$) ta|
|00002a90| 6b 65 73 20 61 20 6b 65 | 79 20 24 6b 24 20 61 6e |kes a ke|y $k$ an|
|00002aa0| 64 20 72 65 74 75 72 6e | 73 20 74 68 65 20 69 74 |d return|s the it|
|00002ab0| 65 6d 20 24 69 74 24 20 | 77 69 74 68 20 63 6f 6e |em $it$ |with con|
|00002ac0| 74 65 6e 74 73 20 0a 24 | 28 6b 2c 69 29 24 20 28 |tents .$|(k,i)$ (|
|00002ad0| 69 74 20 72 65 74 75 72 | 6e 73 20 24 6e 69 6c 24 |it retur|ns $nil$|
|00002ae0| 20 69 66 20 74 68 65 72 | 65 20 69 73 20 6e 6f 20 | if ther|e is no |
|00002af0| 73 75 63 68 20 69 74 65 | 6d 29 2c 20 24 44 24 2e |such ite|m), $D$.|
|00002b00| 69 6e 66 28 24 69 74 24 | 29 20 65 78 74 72 61 63 |inf($it$|) extrac|
|00002b10| 74 73 20 0a 24 69 24 20 | 66 72 6f 6d 20 24 69 74 |ts .$i$ |from $it|
|00002b20| 24 2c 20 61 6e 64 20 61 | 20 6e 65 77 20 76 61 6c |$, and a| new val|
|00002b30| 75 65 20 24 69 5c 27 24 | 20 63 61 6e 20 62 65 20 |ue $i\'$| can be |
|00002b40| 61 73 73 6f 63 69 61 74 | 65 64 20 77 69 74 68 20 |associat|ed with |
|00002b50| 24 6b 24 20 62 79 20 0a | 24 44 24 2e 63 68 61 6e |$k$ by .|$D$.chan|
|00002b60| 67 65 5c 5f 69 6e 66 28 | 24 69 74 2c 69 5c 27 24 |ge\_inf(|$it,i\'$|
|00002b70| 29 2e 0a 0a 0a 4c 65 74 | 20 75 73 20 68 61 76 65 |)....Let| us have|
|00002b80| 20 61 20 6c 6f 6f 6b 20 | 61 74 20 74 68 65 20 69 | a look |at the i|
|00002b90| 6e 73 65 72 74 20 6f 70 | 65 72 61 74 69 6f 6e 20 |nsert op|eration |
|00002ba0| 66 6f 72 20 64 69 63 74 | 69 6f 6e 61 72 69 65 73 |for dict|ionaries|
|00002bb0| 20 6e 65 78 74 3a 0a 0a | 5c 2b 26 24 64 69 63 5c | next:..|\+&$dic\|
|00002bc0| 5f 69 74 65 6d 24 20 26 | 24 44 24 2e 69 6e 73 65 |_item$ &|$D$.inse|
|00002bd0| 72 74 28 24 4b 5c 20 6b | 2c 5c 20 49 5c 20 69 24 |rt($K\ k|,\ I\ i$|
|00002be0| 29 5c 63 72 0a 0a 54 68 | 65 72 65 20 61 72 65 20 |)\cr..Th|ere are |
|00002bf0| 74 77 6f 20 63 61 73 65 | 73 20 74 6f 20 63 6f 6e |two case|s to con|
|00002c00| 73 69 64 65 72 2e 20 49 | 66 20 24 44 24 20 63 6f |sider. I|f $D$ co|
|00002c10| 6e 74 61 69 6e 73 20 61 | 6e 20 69 74 65 6d 20 24 |ntains a|n item $|
|00002c20| 69 74 24 20 77 69 74 68 | 20 63 6f 6e 74 65 6e 74 |it$ with| content|
|00002c30| 73 0a 24 28 6b 2c 69 5c | 27 29 24 20 74 68 65 6e |s.$(k,i\|')$ then|
|00002c40| 20 24 69 5c 27 24 20 69 | 73 20 72 65 70 6c 61 63 | $i\'$ i|s replac|
|00002c50| 65 64 20 62 79 20 24 69 | 24 20 61 6e 64 20 24 69 |ed by $i|$ and $i|
|00002c60| 74 24 20 69 73 20 72 65 | 74 75 72 6e 65 64 2e 20 |t$ is re|turned. |
|00002c70| 49 66 20 24 44 24 20 63 | 6f 6e 74 61 69 6e 73 0a |If $D$ c|ontains.|
|00002c80| 6e 6f 20 73 75 63 68 20 | 69 74 65 6d 2c 20 74 68 |no such |item, th|
|00002c90| 65 6e 20 61 20 6e 65 77 | 20 69 74 65 6d 2c 20 69 |en a new| item, i|
|00002ca0| 2e 65 2e 2c 20 61 6e 20 | 69 74 65 6d 20 77 68 69 |.e., an |item whi|
|00002cb0| 63 68 20 69 73 20 6e 6f | 74 20 63 6f 6e 74 61 69 |ch is no|t contai|
|00002cc0| 6e 65 64 20 69 6e 20 61 | 6e 79 20 0a 64 69 63 74 |ned in a|ny .dict|
|00002cd0| 69 6f 6e 61 72 79 2c 20 | 69 73 20 61 64 64 65 64 |ionary, |is added|
|00002ce0| 20 74 6f 20 24 44 24 2c | 20 74 68 69 73 20 69 74 | to $D$,| this it|
|00002cf0| 65 6d 20 69 73 20 6d 61 | 64 65 20 74 6f 20 63 6f |em is ma|de to co|
|00002d00| 6e 74 61 69 6e 20 24 28 | 6b 2c 69 29 24 20 61 6e |ntain $(|k,i)$ an|
|00002d10| 64 20 69 73 0a 72 65 74 | 75 72 6e 65 64 2e 20 0a |d is.ret|urned. .|
|00002d20| 0a 7b 5c 62 66 20 52 65 | 6d 61 72 6b 73 7d 3a 20 |.{\bf Re|marks}: |
|00002d30| 0a 5c 62 65 67 69 6e 69 | 74 65 6d 0a 0a 5c 69 74 |.\begini|tem..\it|
|00002d40| 65 6d 20 7b 31 2e 7d 0a | 49 6e 20 4c 45 44 41 20 |em {1.}.|In LEDA |
|00002d50| 73 70 65 63 69 66 69 63 | 61 74 69 6f 6e 73 20 77 |specific|ations w|
|00002d60| 65 20 75 73 65 20 0a 5c | 20 60 60 24 54 5f 30 24 |e use .\| ``$T_0$|
|00002d70| 20 5c 71 75 61 64 20 58 | 59 5a 2e 24 6f 70 28 54 | \quad X|YZ.$op(T|
|00002d80| 5f 31 5c 20 74 5f 31 2c | 5c 20 5c 64 6f 74 73 2c |_1\ t_1,|\ \dots,|
|00002d90| 5c 20 54 5f 6b 5c 20 74 | 5f 6b 29 24 27 27 5c 20 |\ T_k\ t|_k)$''\ |
|00002da0| 0a 74 6f 20 64 65 6e 6f | 74 65 20 61 6e 20 6f 70 |.to deno|te an op|
|00002db0| 65 72 61 74 69 6f 6e 20 | 24 6f 70 24 20 61 70 70 |eration |$op$ app|
|00002dc0| 6c 69 65 64 20 74 6f 20 | 61 6e 20 6f 62 6a 65 63 |lied to |an objec|
|00002dd0| 74 20 58 59 5a 20 77 69 | 74 68 20 72 65 73 75 6c |t XYZ wi|th resul|
|00002de0| 74 20 74 79 70 65 20 24 | 54 5f 30 24 20 0a 61 6e |t type $|T_0$ .an|
|00002df0| 64 20 61 72 67 75 6d 65 | 6e 74 73 20 24 74 5f 31 |d argume|nts $t_1|
|00002e00| 2c 5c 64 6f 74 73 2c 5c | 20 74 5f 6b 24 20 6f 66 |,\dots,\| t_k$ of|
|00002e10| 20 74 79 70 65 73 20 24 | 54 5f 31 2c 5c 64 6f 74 | types $|T_1,\dot|
|00002e20| 73 2c 5c 20 54 5f 6b 24 | 20 72 65 73 70 65 63 74 |s,\ T_k$| respect|
|00002e30| 69 76 65 6c 79 2e 0a 0a | 5c 69 74 65 6d 20 7b 32 |ively...|\item {2|
|00002e40| 2e 7d 0a 53 6f 6d 65 20 | 72 65 61 64 65 72 73 20 |.}.Some |readers |
|00002e50| 6d 61 79 20 66 69 6e 64 | 20 69 74 20 75 73 65 66 |may find| it usef|
|00002e60| 75 6c 20 74 6f 20 69 6e | 74 65 72 70 72 65 74 20 |ul to in|terpret |
|00002e70| 61 20 24 64 69 63 5c 5f | 69 74 65 6d 24 20 61 73 |a $dic\_|item$ as|
|00002e80| 0a 61 20 70 6f 69 6e 74 | 65 72 20 74 6f 20 61 20 |.a point|er to a |
|00002e90| 76 61 72 69 61 62 6c 65 | 20 6f 66 20 74 79 70 65 |variable| of type|
|00002ea0| 20 24 4b 5c 74 69 6d 65 | 73 20 49 24 2e 20 54 68 | $K\time|s I$. Th|
|00002eb0| 65 20 64 69 66 66 65 72 | 65 6e 63 65 20 69 73 20 |e differ|ence is |
|00002ec0| 74 68 61 74 20 74 68 65 | 0a 61 73 73 69 67 6e 6d |that the|.assignm|
|00002ed0| 65 6e 74 20 74 6f 20 74 | 68 65 20 76 61 72 69 61 |ent to t|he varia|
|00002ee0| 62 6c 65 20 63 6f 6e 74 | 61 69 6e 65 64 20 69 6e |ble cont|ained in|
|00002ef0| 20 61 20 24 64 69 63 5c | 5f 69 74 65 6d 24 20 69 | a $dic\|_item$ i|
|00002f00| 73 20 72 65 73 74 72 69 | 63 74 65 64 2c 20 65 2e |s restri|cted, e.|
|00002f10| 67 2e 2c 20 74 68 65 0a | 24 4b 24 2d 63 6f 6d 70 |g., the.|$K$-comp|
|00002f20| 6f 6e 65 6e 74 20 63 61 | 6e 6e 6f 74 20 62 65 20 |onent ca|nnot be |
|00002f30| 63 68 61 6e 67 65 64 2c | 20 61 6e 64 20 74 68 61 |changed,| and tha|
|00002f40| 74 20 69 6e 20 72 65 74 | 75 72 6e 20 66 6f 72 20 |t in ret|urn for |
|00002f50| 74 68 69 73 20 72 65 73 | 74 72 69 63 74 69 6f 6e |this res|triction|
|00002f60| 20 74 68 65 0a 61 63 63 | 65 73 73 20 74 6f 20 24 | the.acc|ess to $|
|00002f70| 64 69 63 5c 5f 69 74 65 | 6d 73 24 20 69 73 20 6d |dic\_ite|ms$ is m|
|00002f80| 6f 72 65 20 66 6c 65 78 | 69 62 6c 65 20 74 68 61 |ore flex|ible tha|
|00002f90| 6e 20 66 6f 72 20 6f 72 | 64 69 6e 61 72 79 20 76 |n for or|dinary v|
|00002fa0| 61 72 69 61 62 6c 65 73 | 2c 20 65 2e 67 2e 2c 0a |ariables|, e.g.,.|
|00002fb0| 61 63 63 65 73 73 20 74 | 68 72 6f 75 67 68 20 74 |access t|hrough t|
|00002fc0| 68 65 20 76 61 6c 75 65 | 20 6f 66 20 74 68 65 20 |he value| of the |
|00002fd0| 24 4b 24 2d 63 6f 6d 70 | 6f 6e 65 6e 74 20 69 73 |$K$-comp|onent is|
|00002fe0| 20 70 6f 73 73 69 62 6c | 65 2e 0a 0a 5c 65 6e 64 | possibl|e...\end|
|00002ff0| 69 74 65 6d 0a 0a 44 69 | 63 74 69 6f 6e 61 72 69 |item..Di|ctionari|
|00003000| 65 73 20 61 72 65 20 69 | 6d 70 6c 65 6d 65 6e 74 |es are i|mplement|
|00003010| 65 64 20 62 79 20 6c 65 | 61 66 2d 6f 72 69 65 6e |ed by le|af-orien|
|00003020| 74 65 64 20 72 65 64 2d | 62 6c 61 63 6b 20 74 72 |ted red-|black tr|
|00003030| 65 65 73 2e 0a 4f 70 65 | 72 61 74 69 6f 6e 73 20 |ees..Ope|rations |
|00003040| 69 6e 73 65 72 74 20 61 | 6e 64 20 6c 6f 6f 6b 75 |insert a|nd looku|
|00003050| 70 20 74 61 6b 65 20 74 | 69 6d 65 20 24 4f 28 5c |p take t|ime $O(\|
|00003060| 6c 6f 67 20 6e 29 24 2c | 20 6b 65 79 2c 20 69 6e |log n)$,| key, in|
|00003070| 66 2c 20 61 6e 64 20 63 | 68 61 6e 67 65 5c 5f 69 |f, and c|hange\_i|
|00003080| 6e 66 20 0a 74 61 6b 65 | 20 74 69 6d 65 20 24 4f |nf .take| time $O|
|00003090| 28 31 29 24 2e 20 48 65 | 72 65 20 24 6e 24 20 69 |(1)$. He|re $n$ i|
|000030a0| 73 20 74 68 65 20 63 75 | 72 72 65 6e 74 20 73 69 |s the cu|rrent si|
|000030b0| 7a 65 20 6f 66 20 74 68 | 65 20 64 69 63 74 69 6f |ze of th|e dictio|
|000030c0| 6e 61 72 79 2e 20 0a 54 | 68 65 20 73 70 61 63 65 |nary. .T|he space|
|000030d0| 20 72 65 71 75 69 72 65 | 6d 65 6e 74 20 69 73 20 | require|ment is |
|000030e0| 24 4f 28 6e 29 24 2e 0a | 20 0a 0a 57 65 20 6e 65 |$O(n)$..| ..We ne|
|000030f0| 78 74 20 67 69 76 65 20 | 61 20 73 69 6d 70 6c 65 |xt give |a simple|
|00003100| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 6f 66 20 | applica|tion of |
|00003110| 74 68 65 20 64 69 63 74 | 69 6f 6e 61 72 79 20 64 |the dict|ionary d|
|00003120| 61 74 61 20 74 79 70 65 | 2e 0a 50 72 6f 67 72 61 |ata type|..Progra|
|00003130| 6d 20 31 20 72 65 61 64 | 73 20 61 20 73 65 71 75 |m 1 read|s a sequ|
|00003140| 65 6e 63 65 20 6f 66 20 | 73 74 72 69 6e 67 73 20 |ence of |strings |
|00003150| 74 65 72 6d 69 6e 61 74 | 65 64 20 62 79 20 60 60 |terminat|ed by ``|
|00003160| 73 74 6f 70 27 27 20 61 | 6e 64 20 63 6f 75 6e 74 |stop'' a|nd count|
|00003170| 73 20 74 68 65 20 0a 6e | 75 6d 62 65 72 20 6f 66 |s the .n|umber of|
|00003180| 20 6f 63 63 75 72 72 65 | 6e 63 65 73 20 6f 66 20 | occurre|nces of |
|00003190| 65 61 63 68 20 73 74 72 | 69 6e 67 20 69 6e 20 74 |each str|ing in t|
|000031a0| 68 65 20 73 65 71 75 65 | 6e 63 65 2e 0a 54 68 65 |he seque|nce..The|
|000031b0| 20 6e 75 6d 62 65 72 20 | 6f 66 20 6f 63 63 75 72 | number |of occur|
|000031c0| 72 65 6e 63 65 73 20 69 | 73 20 74 68 65 6e 20 6c |rences i|s then l|
|000031d0| 69 73 74 65 64 20 66 6f | 72 20 65 61 63 68 20 73 |isted fo|r each s|
|000031e0| 74 72 69 6e 67 20 69 6e | 20 74 68 65 0a 73 65 71 |tring in| the.seq|
|000031f0| 75 65 6e 63 65 2e 0a 5c | 62 69 67 73 6b 69 70 0a |uence..\|bigskip.|
|00003200| 5c 63 6c 65 61 72 74 61 | 62 73 0a 5c 2b 5c 20 28 |\clearta|bs.\+\ (|
|00003210| 31 29 5c 20 5c 20 26 7b | 5c 62 66 20 64 65 63 6c |1)\ \ &{|\bf decl|
|00003220| 61 72 65 32 7d 28 64 69 | 63 74 69 6f 6e 61 72 79 |are2}(di|ctionary|
|00003230| 2c 20 73 74 72 69 6e 67 | 2c 20 69 6e 74 29 5c 63 |, string|, int)\c|
|00003240| 72 0a 5c 73 6d 61 6c 6c | 73 6b 69 70 0a 5c 2b 5c |r.\small|skip.\+\|
|00003250| 20 28 32 29 20 26 7b 5c | 62 66 20 6d 61 69 6e 7d | (2) &{\|bf main}|
|00003260| 28 29 5c 63 72 0a 5c 2b | 5c 20 28 33 29 20 26 24 |()\cr.\+|\ (3) &$|
|00003270| 5c 7b 24 5c 20 5c 20 26 | 5c 63 72 0a 5c 2b 5c 20 |\{$\ \ &|\cr.\+\ |
|00003280| 28 34 29 20 26 20 20 26 | 64 69 63 74 69 6f 6e 61 |(4) & &|dictiona|
|00003290| 72 79 28 73 74 72 69 6e | 67 2c 20 69 6e 74 29 20 |ry(strin|g, int) |
|000032a0| 24 44 24 3b 5c 63 72 0a | 5c 73 6d 61 6c 6c 73 6b |$D$;\cr.|\smallsk|
|000032b0| 69 70 0a 5c 2b 5c 20 28 | 35 29 20 26 20 20 26 73 |ip.\+\ (|5) & &s|
|000032c0| 74 72 69 6e 67 20 24 73 | 24 3b 5c 63 72 0a 5c 2b |tring $s|$;\cr.\+|
|000032d0| 5c 20 28 36 29 20 26 20 | 20 26 64 69 63 5c 5f 69 |\ (6) & | &dic\_i|
|000032e0| 74 65 6d 20 24 69 74 24 | 3b 5c 63 72 0a 5c 73 6d |tem $it$|;\cr.\sm|
|000032f0| 61 6c 6c 73 6b 69 70 0a | 5c 2b 5c 20 28 37 29 20 |allskip.|\+\ (7) |
|00003300| 26 20 20 26 7b 5c 62 66 | 20 77 68 69 6c 65 7d 20 |& &{\bf| while} |
|00003310| 26 28 20 28 63 69 6e 20 | 24 3e 3e 20 73 24 29 20 |&( (cin |$>> s$) |
|00003320| 5c 26 5c 26 20 28 24 73 | 24 20 21 3d 20 60 60 73 |\&\& ($s|$ != ``s|
|00003330| 74 6f 70 27 27 29 20 29 | 5c 63 72 0a 5c 2b 5c 20 |top'') )|\cr.\+\ |
|00003340| 28 38 29 20 26 20 20 26 | 5c 20 5c 20 20 26 24 5c |(8) & &|\ \ &$\|
|00003350| 7b 24 20 26 24 69 74 20 | 3d 20 44 24 2e 6c 6f 6f |{$ &$it |= D$.loo|
|00003360| 6b 75 70 28 24 73 24 29 | 3b 5c 63 72 0a 5c 2b 5c |kup($s$)|;\cr.\+\|
|00003370| 20 28 39 29 20 26 20 20 | 26 20 20 20 20 20 26 20 | (9) & |& & |
|00003380| 20 20 20 26 5c 49 46 20 | 28 24 69 74 3d 3d 6e 69 | &\IF |($it==ni|
|00003390| 6c 24 29 20 24 44 24 2e | 69 6e 73 65 72 74 28 24 |l$) $D$.|insert($|
|000033a0| 73 2c 31 24 29 3b 5c 63 | 72 0a 5c 2b 28 31 30 29 |s,1$);\c|r.\+(10)|
|000033b0| 20 26 20 20 26 20 20 20 | 20 20 26 20 20 20 20 26 | & & | & &|
|000033c0| 5c 45 4c 53 45 20 24 44 | 24 2e 63 68 61 6e 67 65 |\ELSE $D|$.change|
|000033d0| 5c 5f 69 6e 66 28 24 69 | 74 24 2c 24 44 24 2e 69 |\_inf($i|t$,$D$.i|
|000033e0| 6e 66 6f 28 24 69 74 24 | 29 2b 31 29 3b 5c 63 72 |nfo($it$|)+1);\cr|
|000033f0| 0a 5c 2b 28 31 31 29 20 | 26 20 20 26 20 20 20 20 |.\+(11) |& & |
|00003400| 20 26 5c 20 24 5c 7d 24 | 5c 63 72 0a 5c 73 6d 61 | &\ $\}$|\cr.\sma|
|00003410| 6c 6c 73 6b 69 70 0a 5c | 2b 28 31 32 29 20 26 20 |llskip.\|+(12) & |
|00003420| 20 26 7b 5c 62 66 20 66 | 6f 72 61 6c 6c 5c 5f 64 | &{\bf f|orall\_d|
|00003430| 69 63 5c 5f 69 74 65 6d | 73 7d 28 24 69 74 2c 44 |ic\_item|s}($it,D|
|00003440| 24 29 20 0a 63 6f 75 74 | 20 24 3c 3c 20 44 24 2e |$) .cout| $<< D$.|
|00003450| 6b 65 79 28 24 69 74 24 | 29 20 24 3c 3c 24 20 60 |key($it$|) $<<$ `|
|00003460| 60 20 20 22 20 24 3c 3c | 24 20 20 24 44 24 2e 69 |` " $<<|$ $D$.i|
|00003470| 6e 66 28 24 69 74 24 29 | 20 24 3c 3c 24 20 60 60 |nf($it$)| $<<$ ``|
|00003480| 24 5c 62 61 63 6b 73 6c | 61 73 68 24 6e 22 3b 5c |$\backsl|ash$n";\|
|00003490| 63 72 0a 5c 73 6d 61 6c | 6c 73 6b 69 70 0a 5c 2b |cr.\smal|lskip.\+|
|000034a0| 28 31 33 29 20 26 5c 20 | 24 5c 7d 24 5c 63 72 0a |(13) &\ |$\}$\cr.|
|000034b0| 5c 6d 65 64 73 6b 69 70 | 0a 5c 63 65 6e 74 65 72 |\medskip|.\center|
|000034c0| 6c 69 6e 65 7b 7b 5c 62 | 66 20 50 72 6f 67 72 61 |line{{\b|f Progra|
|000034d0| 6d 20 31 3a 7d 20 43 6f | 75 6e 74 69 6e 67 20 74 |m 1:} Co|unting t|
|000034e0| 68 65 20 6e 75 6d 62 65 | 72 20 6f 66 20 6f 63 63 |he numbe|r of occ|
|000034f0| 75 72 72 65 6e 63 65 73 | 20 6f 66 20 65 61 63 68 |urrences| of each|
|00003500| 20 65 6c 65 6d 65 6e 74 | 20 6f 66 20 61 20 73 65 | element| of a se|
|00003510| 71 75 65 6e 63 65 20 6f | 66 20 73 74 72 69 6e 67 |quence o|f string|
|00003520| 73 7d 0a 0a 0a 54 68 65 | 20 64 65 74 61 69 6c 73 |s}...The| details|
|00003530| 20 61 72 65 20 61 73 20 | 66 6f 6c 6c 6f 77 73 2e | are as |follows.|
|00003540| 0a 49 6e 20 6c 69 6e 65 | 20 28 31 29 20 74 68 65 |.In line| (1) the|
|00003550| 20 64 69 63 74 69 6f 6e | 61 72 79 20 74 79 70 65 | diction|ary type|
|00003560| 20 64 69 63 74 69 6f 6e | 61 72 79 28 73 74 72 69 | diction|ary(stri|
|00003570| 6e 67 2c 69 6e 74 29 20 | 69 73 20 64 65 66 69 6e |ng,int) |is defin|
|00003580| 65 64 2e 0a 4e 6f 74 65 | 20 74 68 61 74 20 74 68 |ed..Note| that th|
|00003590| 65 20 64 69 63 74 69 6f | 6e 61 72 79 20 6d 6f 64 |e dictio|nary mod|
|000035a0| 75 6c 65 20 70 72 6f 76 | 69 64 65 73 20 64 69 63 |ule prov|ides dic|
|000035b0| 74 69 6f 6e 61 72 69 65 | 73 20 66 72 6f 6d 20 24 |tionarie|s from $|
|000035c0| 4b 24 0a 74 6f 20 24 49 | 24 20 77 68 65 72 65 20 |K$.to $I|$ where |
|000035d0| 24 4b 24 20 61 6e 64 20 | 24 49 24 20 61 72 65 20 |$K$ and |$I$ are |
|000035e0| 74 79 70 65 20 76 61 72 | 69 61 62 6c 65 73 2e 0a |type var|iables..|
|000035f0| 41 20 73 70 65 63 69 66 | 69 63 20 64 69 63 74 69 |A specif|ic dicti|
|00003600| 6f 6e 61 72 79 20 74 79 | 70 65 20 69 73 20 69 6e |onary ty|pe is in|
|00003610| 74 72 6f 64 75 63 65 64 | 20 61 73 20 73 68 6f 77 |troduced| as show|
|00003620| 6e 20 69 6e 20 6c 69 6e | 65 20 28 31 29 2e 0a 4c |n in lin|e (1)..L|
|00003630| 69 6e 65 20 28 34 29 20 | 69 6e 74 72 6f 64 75 63 |ine (4) |introduc|
|00003640| 65 73 20 24 44 24 20 61 | 73 20 74 68 65 20 6e 61 |es $D$ a|s the na|
|00003650| 6d 65 20 6f 66 20 61 6e | 20 6f 62 6a 65 63 74 20 |me of an| object |
|00003660| 6f 66 20 74 79 70 65 0a | 64 69 63 74 69 6f 6e 61 |of type.|dictiona|
|00003670| 72 79 28 73 74 72 69 6e | 67 2c 69 6e 74 29 3b 20 |ry(strin|g,int); |
|00003680| 24 44 24 20 69 73 20 69 | 6e 69 74 69 61 6c 69 7a |$D$ is i|nitializ|
|00003690| 65 64 20 74 6f 20 74 68 | 65 20 65 6d 70 74 79 20 |ed to th|e empty |
|000036a0| 64 69 63 74 69 6f 6e 61 | 72 79 20 0a 4c 69 6e 65 |dictiona|ry .Line|
|000036b0| 73 20 28 37 29 20 74 6f | 20 28 31 31 29 20 73 74 |s (7) to| (11) st|
|000036c0| 65 70 20 74 68 72 6f 75 | 67 68 20 74 68 65 20 69 |ep throu|gh the i|
|000036d0| 6e 70 75 74 20 73 65 71 | 75 65 6e 63 65 2e 20 46 |nput seq|uence. F|
|000036e0| 6f 72 20 65 61 63 68 20 | 73 74 72 69 6e 67 0a 24 |or each |string.$|
|000036f0| 73 24 20 77 65 20 6c 6f | 6f 6b 20 66 6f 72 20 61 |s$ we lo|ok for a|
|00003700| 6e 20 69 74 65 6d 20 77 | 69 74 68 20 6b 65 79 20 |n item w|ith key |
|00003710| 24 73 24 20 28 6c 69 6e | 65 20 38 29 2e 20 49 66 |$s$ (lin|e 8). If|
|00003720| 20 74 68 65 72 65 20 69 | 73 20 6e 6f 20 73 75 63 | there i|s no suc|
|00003730| 68 20 69 74 65 6d 20 0a | 69 6e 20 24 44 24 20 74 |h item .|in $D$ t|
|00003740| 68 65 20 6c 6f 6f 6b 75 | 70 20 6f 70 65 72 61 74 |he looku|p operat|
|00003750| 69 6f 6e 20 72 65 74 75 | 72 6e 73 20 24 6e 69 6c |ion retu|rns $nil|
|00003760| 24 20 61 6e 64 20 77 65 | 20 69 6e 73 65 72 74 20 |$ and we| insert |
|00003770| 74 68 65 20 70 61 69 72 | 20 24 28 73 2c 31 29 24 |the pair| $(s,1)$|
|00003780| 20 0a 28 6c 69 6e 65 20 | 39 29 2e 20 49 66 20 74 | .(line |9). If t|
|00003790| 68 65 72 65 20 69 73 20 | 73 75 63 68 20 61 6e 20 |here is |such an |
|000037a0| 69 74 65 6d 20 77 65 20 | 69 6e 63 72 65 61 73 65 |item we |increase|
|000037b0| 20 69 74 73 20 69 6e 66 | 6f 72 6d 61 74 69 6f 6e | its inf|ormation|
|000037c0| 20 28 6c 69 6e 65 20 31 | 30 29 2e 0a 46 69 6e 61 | (line 1|0)..Fina|
|000037d0| 6c 6c 79 2c 20 6c 69 6e | 65 20 28 31 32 29 20 73 |lly, lin|e (12) s|
|000037e0| 74 65 70 73 20 74 68 72 | 6f 75 67 68 20 61 6c 6c |teps thr|ough all|
|000037f0| 20 69 74 65 6d 73 20 69 | 6e 20 24 44 24 20 61 6e | items i|n $D$ an|
|00003800| 64 20 70 72 69 6e 74 73 | 20 74 68 65 20 63 6f 72 |d prints| the cor|
|00003810| 72 65 73 70 6f 6e 64 69 | 6e 67 0a 6b 65 79 20 61 |respondi|ng.key a|
|00003820| 6e 64 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 20 76 |nd infor|mation v|
|00003830| 61 6c 75 65 73 2e 0a 0a | 54 68 65 20 72 75 6e 6e |alues...|The runn|
|00003840| 69 6e 67 20 74 69 6d 65 | 20 6f 66 20 70 72 6f 67 |ing time| of prog|
|00003850| 72 61 6d 7e 31 20 6f 6e | 20 61 20 73 65 71 75 65 |ram~1 on| a seque|
|00003860| 6e 63 65 20 6f 66 20 24 | 6e 24 20 73 74 72 69 6e |nce of $|n$ strin|
|00003870| 67 73 20 69 73 20 24 4f | 28 6e 5c 6c 6f 67 20 6e |gs is $O|(n\log n|
|00003880| 29 24 2c 0a 73 69 6e 63 | 65 20 74 68 65 20 70 72 |)$,.sinc|e the pr|
|00003890| 6f 67 72 61 6d 20 65 78 | 65 63 75 74 65 73 20 24 |ogram ex|ecutes $|
|000038a0| 6e 24 20 6c 6f 6f 6b 75 | 70 20 61 6e 64 20 61 74 |n$ looku|p and at|
|000038b0| 20 6d 6f 73 74 20 24 6e | 24 20 69 6e 73 65 72 74 | most $n|$ insert|
|000038c0| 20 6f 70 65 72 61 74 69 | 6f 6e 73 0a 6f 6e 20 24 | operati|ons.on $|
|000038d0| 44 24 20 66 6f 72 20 61 | 20 63 6f 73 74 20 6f 66 |D$ for a| cost of|
|000038e0| 20 24 4f 28 5c 6c 6f 67 | 20 6e 29 24 20 65 61 63 | $O(\log| n)$ eac|
|000038f0| 68 20 61 6e 64 20 73 69 | 6e 63 65 20 74 68 65 20 |h and si|nce the |
|00003900| 72 65 6d 61 69 6e 69 6e | 67 20 24 4f 28 6e 29 24 |remainin|g $O(n)$|
|00003910| 0a 6f 70 65 72 61 74 69 | 6f 6e 73 20 74 61 6b 65 |.operati|ons take|
|00003920| 20 63 6f 6e 73 74 61 6e | 74 20 74 69 6d 65 20 65 | constan|t time e|
|00003930| 61 63 68 2e 20 54 68 65 | 20 75 73 65 20 6f 66 20 |ach. The| use of |
|00003940| 69 74 65 6d 73 20 69 73 | 20 6e 6f 74 20 65 73 73 |items is| not ess|
|00003950| 65 6e 74 69 61 6c 0a 66 | 6f 72 20 74 68 65 20 61 |ential.f|or the a|
|00003960| 73 79 6d 70 74 6f 74 69 | 63 20 72 75 6e 6e 69 6e |symptoti|c runnin|
|00003970| 67 20 74 69 6d 65 20 6f | 66 20 70 72 6f 67 72 61 |g time o|f progra|
|00003980| 6d 7e 31 2e 20 45 76 65 | 6e 20 69 66 20 61 20 63 |m~1. Eve|n if a c|
|00003990| 68 61 6e 67 65 5c 5f 69 | 6e 66 0a 6f 70 65 72 61 |hange\_i|nf.opera|
|000039a0| 74 69 6f 6e 20 77 6f 75 | 6c 64 20 68 61 76 65 20 |tion wou|ld have |
|000039b0| 63 6f 73 74 20 24 4f 28 | 5c 6c 6f 67 20 6e 29 24 |cost $O(|\log n)$|
|000039c0| 2c 20 74 68 65 20 61 73 | 79 6d 70 74 6f 74 69 63 |, the as|ymptotic|
|000039d0| 20 72 75 6e 6e 69 6e 67 | 20 74 69 6d 65 0a 77 6f | running| time.wo|
|000039e0| 75 6c 64 20 73 74 69 6c | 6c 20 62 65 20 24 4f 28 |uld stil|l be $O(|
|000039f0| 6e 5c 6c 6f 67 20 6e 29 | 24 2c 20 61 6c 74 68 6f |n\log n)|$, altho|
|00003a00| 75 67 68 20 77 69 74 68 | 20 61 20 6c 61 72 67 65 |ugh with| a large|
|00003a10| 72 20 63 6f 6e 73 74 61 | 6e 74 20 66 61 63 74 6f |r consta|nt facto|
|00003a20| 72 2e 0a 46 6f 72 20 74 | 68 65 20 6e 65 78 74 20 |r..For t|he next |
|00003a30| 65 78 61 6d 70 6c 65 20 | 74 68 65 20 75 73 65 20 |example |the use |
|00003a40| 6f 66 20 69 74 65 6d 73 | 20 69 73 20 65 73 73 65 |of items| is esse|
|00003a50| 6e 74 69 61 6c 2e 0a 0a | 0a 5c 62 69 67 73 6b 69 |ntial...|.\bigski|
|00003a60| 70 0a 5c 62 69 67 73 6b | 69 70 0a 7b 5c 6d 61 67 |p.\bigsk|ip.{\mag|
|00003a70| 6f 6e 65 20 45 78 61 6d | 70 6c 65 20 32 3a 20 50 |one Exam|ple 2: P|
|00003a80| 72 69 6f 72 69 74 79 20 | 51 75 65 75 65 73 7d 20 |riority |Queues} |
|00003a90| 0a 0a 50 72 69 6f 72 69 | 74 79 20 71 75 65 75 65 |..Priori|ty queue|
|00003aa0| 73 20 61 72 65 20 61 20 | 76 61 72 69 61 74 69 6f |s are a |variatio|
|00003ab0| 6e 20 6f 66 20 64 69 63 | 74 69 6f 6e 61 72 69 65 |n of dic|tionarie|
|00003ac0| 73 3b 20 74 68 65 79 20 | 64 69 66 66 65 72 20 69 |s; they |differ i|
|00003ad0| 6e 20 74 68 72 65 65 0a | 61 73 70 65 63 74 73 20 |n three.|aspects |
|00003ae0| 66 72 6f 6d 20 64 69 63 | 74 69 6f 6e 61 72 69 65 |from dic|tionarie|
|00003af0| 73 3a 20 66 69 72 73 74 | 6c 79 2c 20 74 68 65 20 |s: first|ly, the |
|00003b00| 73 65 74 20 24 49 24 20 | 6f 66 20 69 6e 66 6f 72 |set $I$ |of infor|
|00003b10| 6d 61 74 69 6f 6e 73 20 | 6d 75 73 74 0a 62 65 20 |mations |must.be |
|00003b20| 6c 69 6e 65 61 72 6c 79 | 20 6f 72 64 65 72 65 64 |linearly| ordered|
|00003b30| 2c 20 73 65 63 6f 6e 64 | 6c 79 2c 20 74 68 65 72 |, second|ly, ther|
|00003b40| 65 20 69 73 20 61 6e 20 | 6f 70 65 72 61 74 69 6f |e is an |operatio|
|00003b50| 6e 20 66 69 6e 64 6d 69 | 6e 28 29 20 77 68 69 63 |n findmi|n() whic|
|00003b60| 68 0a 72 65 74 75 72 6e | 73 20 61 6e 20 69 74 65 |h.return|s an ite|
|00003b70| 6d 20 77 69 74 68 20 6d | 69 6e 69 6d 61 6c 20 69 |m with m|inimal i|
|00003b80| 6e 66 6f 72 6d 61 74 69 | 6f 6e 2c 20 61 6e 64 20 |nformati|on, and |
|00003b90| 74 68 69 72 64 6c 79 2c | 20 74 68 65 72 65 20 69 |thirdly,| there i|
|00003ba0| 73 20 61 20 0a 72 65 73 | 74 72 69 63 74 65 64 20 |s a .res|tricted |
|00003bb0| 63 68 61 6e 67 65 5c 5f | 69 6e 66 20 6f 70 65 72 |change\_|inf oper|
|00003bc0| 61 74 69 6f 6e 20 64 65 | 63 72 65 61 73 65 5c 5f |ation de|crease\_|
|00003bd0| 69 6e 66 28 24 69 74 2c | 69 24 29 20 77 68 69 63 |inf($it,|i$) whic|
|00003be0| 68 20 64 65 63 72 65 61 | 73 65 73 0a 74 68 65 20 |h decrea|ses.the |
|00003bf0| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 20 73 74 6f 72 |informat|ion stor|
|00003c00| 65 64 20 69 6e 20 69 74 | 65 6d 20 24 69 74 24 20 |ed in it|em $it$ |
|00003c10| 74 6f 20 24 69 24 2e 20 | 54 68 65 20 6f 70 65 72 |to $i$. |The oper|
|00003c20| 61 74 69 6f 6e 20 72 61 | 69 73 65 73 20 61 6e 20 |ation ra|ises an |
|00003c30| 65 72 72 6f 72 0a 69 66 | 20 24 69 24 20 69 73 20 |error.if| $i$ is |
|00003c40| 6c 61 72 67 65 72 20 74 | 68 61 6e 20 74 68 65 20 |larger t|han the |
|00003c50| 6f 6c 64 20 69 6e 66 6f | 72 6d 61 74 69 6f 6e 20 |old info|rmation |
|00003c60| 73 74 6f 72 65 64 20 69 | 6e 20 69 74 65 6d 20 24 |stored i|n item $|
|00003c70| 69 74 24 2e 0a 46 69 67 | 75 72 65 7e 31 20 73 68 |it$..Fig|ure~1 sh|
|00003c80| 6f 77 73 20 74 68 65 20 | 73 70 65 63 69 66 69 63 |ows the |specific|
|00003c90| 61 74 69 6f 6e 20 6f 66 | 20 74 68 65 20 64 61 74 |ation of| the dat|
|00003ca0| 61 20 74 79 70 65 20 70 | 72 69 6f 72 69 74 79 20 |a type p|riority |
|00003cb0| 71 75 65 75 65 20 61 73 | 20 67 69 76 65 6e 0a 69 |queue as| given.i|
|00003cc0| 6e 20 74 68 65 20 4c 45 | 44 41 20 6d 61 6e 75 61 |n the LE|DA manua|
|00003cd0| 6c 20 28 5b 4e 39 30 5d | 29 2e 0a 0a 50 72 69 6f |l ([N90]|)...Prio|
|00003ce0| 72 69 74 79 20 71 75 65 | 75 65 73 20 61 72 65 20 |rity que|ues are |
|00003cf0| 66 72 65 71 75 65 6e 74 | 6c 79 20 75 73 65 64 20 |frequent|ly used |
|00003d00| 69 6e 20 6e 65 74 77 6f | 72 6b 20 61 6c 67 6f 72 |in netwo|rk algor|
|00003d10| 69 74 68 6d 73 2c 20 65 | 2e 67 2e 2c 20 73 68 6f |ithms, e|.g., sho|
|00003d20| 72 74 65 73 74 0a 70 61 | 74 68 73 2c 20 6d 69 6e |rtest.pa|ths, min|
|00003d30| 69 6d 75 6d 20 73 70 61 | 6e 6e 69 6e 67 20 74 72 |imum spa|nning tr|
|00003d40| 65 65 2c 20 61 6e 64 20 | 6d 61 78 69 6d 75 6d 20 |ee, and |maximum |
|00003d50| 66 6c 6f 77 20 63 6f 6d | 70 75 74 61 74 69 6f 6e |flow com|putation|
|00003d60| 73 2e 20 49 6e 20 74 68 | 65 73 65 0a 61 70 70 6c |s. In th|ese.appl|
|00003d70| 69 63 61 74 69 6f 6e 73 | 20 74 68 65 20 64 65 63 |ications| the dec|
|00003d80| 72 65 61 73 65 5c 5f 69 | 6e 66 20 6f 70 65 72 61 |rease\_i|nf opera|
|00003d90| 74 69 6f 6e 20 69 73 20 | 74 79 70 69 63 61 6c 6c |tion is |typicall|
|00003da0| 79 20 65 78 65 63 75 74 | 65 64 20 6d 6f 72 65 20 |y execut|ed more |
|00003db0| 6f 66 74 65 6e 0a 74 68 | 61 6e 20 74 68 65 20 6f |often.th|an the o|
|00003dc0| 74 68 65 72 20 70 72 69 | 6f 72 69 74 79 20 71 75 |ther pri|ority qu|
|00003dd0| 65 75 65 20 6f 70 65 72 | 61 74 69 6f 6e 73 2c 20 |eue oper|ations, |
|00003de0| 65 2e 67 2e 2c 20 69 6e | 20 44 69 6a 6b 73 74 72 |e.g., in| Dijkstr|
|00003df0| 61 27 73 20 61 6c 67 6f | 72 69 74 68 6d 0a 66 6f |a's algo|rithm.fo|
|00003e00| 72 20 73 68 6f 72 74 65 | 73 74 20 70 61 74 68 73 |r shorte|st paths|
|00003e10| 20 28 63 66 2e 20 70 72 | 6f 67 72 61 6d 7e 33 20 | (cf. pr|ogram~3 |
|00003e20| 69 6e 20 73 65 63 74 69 | 6f 6e 20 49 49 49 29 20 |in secti|on III) |
|00003e30| 64 65 63 72 65 61 73 65 | 5c 5f 69 6e 66 20 69 73 |decrease|\_inf is|
|00003e40| 0a 65 78 65 63 75 74 65 | 64 20 24 6d 24 20 74 69 |.execute|d $m$ ti|
|00003e50| 6d 65 73 20 61 6e 64 20 | 74 68 65 20 6f 74 68 65 |mes and |the othe|
|00003e60| 72 20 6f 70 65 72 61 74 | 69 6f 6e 73 20 61 72 65 |r operat|ions are|
|00003e70| 20 65 78 65 63 75 74 65 | 64 20 24 6e 24 20 74 69 | execute|d $n$ ti|
|00003e80| 6d 65 73 2e 0a 48 65 72 | 65 20 24 6d 24 20 61 6e |mes..Her|e $m$ an|
|00003e90| 64 20 24 6e 24 20 64 65 | 6e 6f 74 65 20 74 68 65 |d $n$ de|note the|
|00003ea0| 20 6e 75 6d 62 65 72 20 | 6f 66 20 65 64 67 65 73 | number |of edges|
|00003eb0| 20 61 6e 64 20 76 65 72 | 74 69 63 65 73 20 6f 66 | and ver|tices of|
|00003ec0| 20 74 68 65 20 6e 65 74 | 77 6f 72 6b 0a 72 65 73 | the net|work.res|
|00003ed0| 70 65 63 74 69 76 65 6c | 79 2e 20 4e 6f 74 65 20 |pectivel|y. Note |
|00003ee0| 74 68 61 74 20 24 6d 24 | 20 63 61 6e 20 62 65 20 |that $m$| can be |
|00003ef0| 61 73 20 6c 61 72 67 65 | 20 61 73 20 24 6e 5e 32 |as large| as $n^2|
|00003f00| 24 2e 0a 0a 53 65 76 65 | 72 61 6c 20 72 65 63 65 |$...Seve|ral rece|
|00003f10| 6e 74 20 70 61 70 65 72 | 73 2c 20 65 2e 67 2e 20 |nt paper|s, e.g. |
|00003f20| 5b 46 54 38 37 5d 20 61 | 6e 64 20 5b 41 4d 4f 54 |[FT87] a|nd [AMOT|
|00003f30| 39 30 5d 2c 20 68 61 76 | 65 20 73 68 6f 77 6e 20 |90], hav|e shown |
|00003f40| 74 68 61 74 20 74 68 65 | 20 0a 64 65 63 72 65 61 |that the| .decrea|
|00003f50| 73 65 5c 5f 69 6e 66 20 | 6f 70 65 72 61 74 69 6f |se\_inf |operatio|
|00003f60| 6e 20 63 61 6e 20 62 65 | 20 72 65 61 6c 69 7a 65 |n can be| realize|
|00003f70| 64 20 69 6e 20 74 69 6d | 65 20 24 4f 28 31 29 24 |d in tim|e $O(1)$|
|00003f80| 20 61 6e 64 20 61 6c 6c | 20 6f 74 68 65 72 0a 6f | and all| other.o|
|00003f90| 70 65 72 61 74 69 6f 6e | 73 20 69 6e 20 74 69 6d |peration|s in tim|
|00003fa0| 65 20 24 4f 28 5c 6c 6f | 67 20 6e 29 24 2e 20 54 |e $O(\lo|g n)$. T|
|00003fb0| 68 69 73 20 6c 65 64 20 | 74 6f 20 61 20 24 4f 28 |his led |to a $O(|
|00003fc0| 6d 2b 6e 5c 6c 6f 67 20 | 6e 29 24 20 69 6d 70 6c |m+n\log |n)$ impl|
|00003fd0| 65 6d 65 6e 74 61 74 69 | 6f 6e 0a 6f 66 20 44 69 |ementati|on.of Di|
|00003fe0| 6a 6b 73 74 72 61 27 73 | 20 61 6c 67 6f 72 69 74 |jkstra's| algorit|
|00003ff0| 68 6d 2e 20 46 6f 72 20 | 74 68 65 20 63 6f 6e 73 |hm. For |the cons|
|00004000| 74 61 6e 74 20 74 69 6d | 65 20 69 6d 70 6c 65 6d |tant tim|e implem|
|00004010| 65 6e 74 61 74 69 6f 6e | 20 6f 66 20 64 65 63 72 |entation| of decr|
|00004020| 65 61 73 65 5c 5f 69 6e | 66 0a 69 74 20 69 73 20 |ease\_in|f.it is |
|00004030| 61 62 73 6f 6c 75 74 65 | 6c 79 20 63 72 75 63 69 |absolute|ly cruci|
|00004040| 61 6c 20 74 68 61 74 20 | 74 68 65 20 69 6e 66 6f |al that |the info|
|00004050| 72 6d 61 74 69 6f 6e 20 | 74 6f 20 62 65 20 63 68 |rmation |to be ch|
|00004060| 61 6e 67 65 64 20 69 6e | 20 74 68 65 20 64 61 74 |anged in| the dat|
|00004070| 61 0a 73 74 72 75 63 74 | 75 72 65 20 69 73 20 61 |a.struct|ure is a|
|00004080| 63 63 65 73 73 65 64 20 | 64 69 72 65 63 74 6c 79 |ccessed |directly|
|00004090| 20 74 68 72 6f 75 67 68 | 20 69 74 73 20 70 6f 73 | through| its pos|
|000040a0| 69 74 69 6f 6e 20 69 6e | 20 74 68 65 20 64 61 74 |ition in| the dat|
|000040b0| 61 20 73 74 72 75 63 74 | 75 72 65 0a 61 6e 64 20 |a struct|ure.and |
|000040c0| 6e 6f 74 20 74 68 72 6f | 75 67 68 20 74 68 65 20 |not thro|ugh the |
|000040d0| 61 73 73 6f 63 69 61 74 | 65 64 20 6b 65 79 2e 20 |associat|ed key. |
|000040e0| 41 20 6c 6f 6f 6b 75 70 | 20 62 79 20 6b 65 79 20 |A lookup| by key |
|000040f0| 77 6f 75 6c 64 20 6e 65 | 63 65 73 73 61 72 69 6c |would ne|cessaril|
|00004100| 79 0a 68 61 76 65 20 6c | 6f 67 61 72 69 74 68 6d |y.have l|ogarithm|
|00004110| 69 63 20 63 6f 73 74 2e | 20 49 6e 20 4c 45 44 41 |ic cost.| In LEDA|
|00004120| 20 61 63 63 65 73 73 20 | 62 79 20 70 6f 73 69 74 | access |by posit|
|00004130| 69 6f 6e 20 69 73 20 61 | 63 68 69 65 76 65 64 20 |ion is a|chieved |
|00004140| 62 79 20 74 68 65 20 69 | 74 65 6d 0a 63 6f 6e 63 |by the i|tem.conc|
|00004150| 65 70 74 20 69 6e 20 61 | 20 6e 61 74 75 72 61 6c |ept in a| natural|
|00004160| 20 77 61 79 20 62 79 20 | 73 69 6d 70 6c 79 20 64 | way by |simply d|
|00004170| 65 66 69 6e 69 6e 67 20 | 70 72 69 6f 72 69 74 79 |efining |priority|
|00004180| 20 71 75 65 75 65 73 20 | 61 73 20 63 6f 6c 6c 65 | queues |as colle|
|00004190| 63 74 69 6f 6e 73 0a 6f | 66 20 70 71 5c 5f 69 74 |ctions.o|f pq\_it|
|000041a0| 65 6d 73 20 61 6e 64 20 | 6d 61 6b 69 6e 67 20 74 |ems and |making t|
|000041b0| 68 65 20 66 69 72 73 74 | 20 61 72 67 75 6d 65 6e |he first| argumen|
|000041c0| 74 20 6f 66 20 64 65 63 | 72 65 61 73 65 5c 5f 69 |t of dec|rease\_i|
|000041d0| 6e 66 20 61 20 70 71 5c | 5f 69 74 65 6d 2e 0a 0a |nf a pq\|_item...|
|000041e0| 5c 62 69 67 73 6b 69 70 | 0a 7b 5c 62 66 20 52 65 |\bigskip|.{\bf Re|
|000041f0| 6d 61 72 6b 7d 3a 20 54 | 68 65 20 73 70 65 63 69 |mark}: T|he speci|
|00004200| 66 69 63 61 74 69 6f 6e | 20 6f 66 20 70 72 69 6f |fication| of prio|
|00004210| 72 69 74 79 20 71 75 65 | 75 65 73 20 67 69 76 65 |rity que|ues give|
|00004220| 6e 20 61 62 6f 76 65 20 | 64 69 66 66 65 72 73 0a |n above |differs.|
|00004230| 66 72 6f 6d 20 74 68 65 | 20 6f 6e 65 20 67 69 76 |from the| one giv|
|00004240| 65 6e 20 69 6e 20 5b 46 | 54 38 37 5d 2c 20 5b 41 |en in [F|T87], [A|
|00004250| 4d 4f 54 39 30 5d 20 61 | 6e 64 20 5b 43 4c 52 39 |MOT90] a|nd [CLR9|
|00004260| 30 5d 2e 20 54 68 65 72 | 65 2c 20 69 6e 73 65 72 |0]. Ther|e, inser|
|00004270| 74 20 74 61 6b 65 73 0a | 61 20 6e 65 77 20 69 74 |t takes.|a new it|
|00004280| 65 6d 20 77 69 74 68 20 | 61 20 70 72 65 64 65 66 |em with |a predef|
|00004290| 69 6e 65 64 20 63 6f 6e | 74 65 6e 74 73 20 24 28 |ined con|tents $(|
|000042a0| 6b 2c 69 29 24 20 61 73 | 20 61 72 67 75 6d 65 6e |k,i)$ as| argumen|
|000042b0| 74 20 61 6e 64 20 69 6e | 73 65 72 74 73 20 69 74 |t and in|serts it|
|000042c0| 0a 69 6e 74 6f 20 74 68 | 65 20 71 75 65 75 65 2c |.into th|e queue,|
|000042d0| 20 69 2e 65 2e 2c 20 69 | 74 20 69 73 20 74 68 65 | i.e., i|t is the|
|000042e0| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 70 72 6f | applica|tion pro|
|000042f0| 67 72 61 6d 27 73 20 74 | 61 73 6b 20 74 6f 20 63 |gram's t|ask to c|
|00004300| 72 65 61 74 65 20 6e 65 | 77 0a 69 74 65 6d 73 2e |reate ne|w.items.|
|00004310| 20 54 68 69 73 20 65 69 | 74 68 65 72 20 72 65 71 | This ei|ther req|
|00004320| 75 69 72 65 73 20 74 68 | 65 20 61 70 70 6c 69 63 |uires th|e applic|
|00004330| 61 74 69 6f 6e 20 74 6f | 20 6b 6e 6f 77 20 74 68 |ation to| know th|
|00004340| 65 20 69 6e 74 65 72 6e | 61 6c 20 73 74 72 75 63 |e intern|al struc|
|00004350| 74 75 72 65 0a 6f 66 20 | 69 74 65 6d 73 2c 20 77 |ture.of |items, w|
|00004360| 68 69 63 68 20 76 69 6f | 6c 61 74 65 73 20 74 68 |hich vio|lates th|
|00004370| 65 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 20 68 69 |e inform|ation hi|
|00004380| 64 69 6e 67 20 70 72 69 | 6e 63 69 70 6c 65 20 6f |ding pri|nciple o|
|00004390| 66 20 61 62 73 74 72 61 | 63 74 20 64 61 74 61 20 |f abstra|ct data |
|000043a0| 0a 74 79 70 65 73 2c 20 | 6f 72 20 69 74 20 72 65 |.types, |or it re|
|000043b0| 71 75 69 72 65 73 20 61 | 6e 20 61 64 64 69 74 69 |quires a|n additi|
|000043c0| 6f 6e 61 6c 20 6f 70 65 | 72 61 74 69 6f 6e 20 74 |onal ope|ration t|
|000043d0| 6f 20 63 72 65 61 74 65 | 20 69 74 65 6d 73 2c 20 |o create| items, |
|000043e0| 77 68 69 63 68 20 69 73 | 2c 0a 68 6f 77 65 76 65 |which is|,.howeve|
|000043f0| 72 2c 20 6e 6f 74 20 70 | 61 72 74 20 6f 66 20 74 |r, not p|art of t|
|00004400| 68 65 20 73 70 65 63 69 | 66 69 63 61 74 69 6f 6e |he speci|fication|
|00004410| 20 67 69 76 65 6e 20 69 | 6e 20 74 68 65 73 65 20 | given i|n these |
|00004420| 70 61 70 65 72 73 2e 0a | 49 6e 20 4c 45 44 41 20 |papers..|In LEDA |
|00004430| 74 68 65 20 71 75 65 75 | 65 20 69 74 73 65 6c 66 |the queu|e itself|
|00004440| 20 63 72 65 61 74 65 73 | 20 74 68 65 20 69 74 65 | creates| the ite|
|00004450| 6d 73 2e 20 54 68 69 73 | 20 70 6f 69 6e 74 20 6f |ms. This| point o|
|00004460| 66 20 76 69 65 77 20 6c | 65 61 64 73 20 74 6f 20 |f view l|eads to |
|00004470| 61 6e 0a 65 6c 65 67 61 | 6e 74 20 73 70 65 63 69 |an.elega|nt speci|
|00004480| 66 69 63 61 74 69 6f 6e | 20 77 68 69 63 68 20 63 |fication| which c|
|00004490| 6f 6d 70 6c 65 74 65 6c | 79 20 73 65 70 61 72 61 |ompletel|y separa|
|000044a0| 74 65 73 20 64 61 74 61 | 20 74 79 70 65 20 61 6e |tes data| type an|
|000044b0| 64 20 61 70 70 6c 69 63 | 61 74 69 6f 6e 0a 70 72 |d applic|ation.pr|
|000044c0| 6f 67 72 61 6d 2e 0a 0a | 5c 76 66 69 6c 6c 5c 65 |ogram...|\vfill\e|
|000044d0| 6a 65 63 74 0a 0a 5c 76 | 62 6f 78 20 74 6f 5c 76 |ject..\v|box to\v|
|000044e0| 73 69 7a 65 7b 0a 5c 68 | 72 75 6c 65 0a 7b 5c 62 |size{.\h|rule.{\b|
|000044f0| 66 20 50 72 69 6f 72 69 | 74 79 20 51 75 65 75 65 |f Priori|ty Queue|
|00004500| 73 20 28 70 72 69 6f 72 | 69 74 79 5c 5f 71 75 65 |s (prior|ity\_que|
|00004510| 75 65 29 7d 0a 5c 73 6d | 61 6c 6c 73 6b 69 70 0a |ue)}.\sm|allskip.|
|00004520| 41 6e 20 69 6e 73 74 61 | 6e 63 65 20 24 51 24 20 |An insta|nce $Q$ |
|00004530| 6f 66 20 74 68 65 20 64 | 61 74 61 20 74 79 70 65 |of the d|ata type|
|00004540| 20 24 70 72 69 6f 72 69 | 74 79 5c 5f 71 75 65 75 | $priori|ty\_queu|
|00004550| 65 24 20 0a 69 73 20 61 | 20 63 6f 6c 6c 65 63 74 |e$ .is a| collect|
|00004560| 69 6f 6e 20 6f 66 20 69 | 74 65 6d 73 20 28 24 70 |ion of i|tems ($p|
|00004570| 71 5c 5f 69 74 65 6d 24 | 29 2e 0a 45 76 65 72 79 |q\_item$|)..Every|
|00004580| 20 69 74 65 6d 20 63 6f | 6e 74 61 69 6e 73 20 61 | item co|ntains a|
|00004590| 20 6b 65 79 20 66 72 6f | 6d 20 61 20 74 79 70 65 | key fro|m a type|
|000045a0| 20 4b 20 61 6e 64 20 61 | 6e 20 69 6e 66 6f 72 6d | K and a|n inform|
|000045b0| 61 74 69 6f 6e 20 66 72 | 6f 6d 20 61 20 74 79 70 |ation fr|om a typ|
|000045c0| 65 20 24 49 24 2e 20 0a | 24 4b 24 20 69 73 20 63 |e $I$. .|$K$ is c|
|000045d0| 61 6c 6c 65 64 20 74 68 | 65 20 6b 65 79 20 74 79 |alled th|e key ty|
|000045e0| 70 65 20 6f 66 20 24 51 | 24 20 61 6e 64 20 24 49 |pe of $Q|$ and $I|
|000045f0| 24 20 69 73 20 63 61 6c | 6c 65 64 20 74 68 65 20 |$ is cal|led the |
|00004600| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 20 74 79 70 65 |informat|ion type|
|00004610| 20 6f 66 20 0a 24 51 24 | 2e 20 54 68 65 20 6e 75 | of .$Q$|. The nu|
|00004620| 6d 62 65 72 20 6f 66 20 | 69 74 65 6d 73 20 69 6e |mber of |items in|
|00004630| 20 24 51 24 20 69 73 20 | 63 61 6c 6c 65 64 20 74 | $Q$ is |called t|
|00004640| 68 65 20 73 69 7a 65 20 | 6f 66 20 24 51 24 2e 20 |he size |of $Q$. |
|00004650| 49 66 20 24 51 24 20 68 | 61 73 20 73 69 7a 65 20 |If $Q$ h|as size |
|00004660| 0a 7a 65 72 6f 20 69 74 | 20 69 73 20 63 61 6c 6c |.zero it| is call|
|00004670| 65 64 20 74 68 65 20 65 | 6d 70 74 79 20 70 72 69 |ed the e|mpty pri|
|00004680| 6f 72 69 74 79 20 71 75 | 65 75 65 2e 20 57 65 20 |ority qu|eue. We |
|00004690| 75 73 65 20 24 3c 6b 2c | 69 3e 24 20 74 6f 20 64 |use $<k,|i>$ to d|
|000046a0| 65 6e 6f 74 65 20 74 68 | 65 20 0a 24 70 71 5c 5f |enote th|e .$pq\_|
|000046b0| 69 74 65 6d 24 5c 20 77 | 69 74 68 20 6b 65 79 20 |item$\ w|ith key |
|000046c0| 24 6b 24 20 61 6e 64 20 | 69 6e 66 6f 72 6d 61 74 |$k$ and |informat|
|000046d0| 69 6f 6e 20 24 69 24 2e | 20 54 68 65 72 65 20 6d |ion $i$.| There m|
|000046e0| 75 73 74 20 65 78 69 73 | 74 20 61 20 6c 69 6e 65 |ust exis|t a line|
|000046f0| 61 72 20 6f 72 64 65 72 | 0a 6f 6e 20 24 49 24 2e |ar order|.on $I$.|
|00004700| 0a 5c 73 6d 61 6c 6c 73 | 6b 69 70 0a 7b 5c 62 66 |.\smalls|kip.{\bf|
|00004710| 20 31 2e 20 44 65 63 6c | 61 72 61 74 69 6f 6e 20 | 1. Decl|aration |
|00004720| 6f 66 20 61 20 70 72 69 | 6f 72 69 74 79 20 71 75 |of a pri|ority qu|
|00004730| 65 75 65 20 74 79 70 65 | 20 7d 0a 5c 73 6d 61 6c |eue type| }.\smal|
|00004740| 6c 73 6b 69 70 0a 5c 64 | 65 63 6c 74 77 6f 20 70 |lskip.\d|ecltwo p|
|00004750| 72 69 6f 72 69 74 79 5c | 5f 71 75 65 75 65 20 4b |riority\|_queue K|
|00004760| 20 49 20 0a 5c 73 6d 61 | 6c 6c 73 6b 69 70 0a 69 | I .\sma|llskip.i|
|00004770| 6e 74 72 6f 64 75 63 65 | 73 20 61 20 6e 65 77 20 |ntroduce|s a new |
|00004780| 64 61 74 61 20 74 79 70 | 65 20 77 69 74 68 20 6e |data typ|e with n|
|00004790| 61 6d 65 20 5c 6e 61 6d | 65 5c 20 63 6f 6e 73 69 |ame \nam|e\ consi|
|000047a0| 73 74 69 6e 67 20 6f 66 | 20 61 6c 6c 0a 70 72 69 |sting of| all.pri|
|000047b0| 6f 72 69 74 79 20 71 75 | 65 75 65 73 20 77 69 74 |ority qu|eues wit|
|000047c0| 68 20 6b 65 79 20 74 79 | 70 65 20 24 4b 24 20 61 |h key ty|pe $K$ a|
|000047d0| 6e 64 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 20 74 |nd infor|mation t|
|000047e0| 79 70 65 20 24 49 24 2e | 0a 5c 73 6d 61 6c 6c 73 |ype $I$.|.\smalls|
|000047f0| 6b 69 70 0a 7b 5c 62 66 | 20 32 2e 20 43 72 65 61 |kip.{\bf| 2. Crea|
|00004800| 74 69 6f 6e 20 6f 66 20 | 61 20 70 72 69 6f 72 69 |tion of |a priori|
|00004810| 74 79 20 71 75 65 75 65 | 7d 0a 5c 73 6d 61 6c 6c |ty queue|}.\small|
|00004820| 73 6b 69 70 0a 5c 63 72 | 65 61 74 65 20 51 20 7b |skip.\cr|eate Q {|
|00004830| 7d 0a 5c 73 6d 61 6c 6c | 73 6b 69 70 0a 63 72 65 |}.\small|skip.cre|
|00004840| 61 74 65 73 20 61 6e 20 | 69 6e 73 74 61 6e 63 65 |ates an |instance|
|00004850| 20 5c 76 61 72 5c 20 6f | 66 20 74 79 70 65 20 5c | \var\ o|f type \|
|00004860| 6e 61 6d 65 5c 20 61 6e | 64 20 69 6e 69 74 69 61 |name\ an|d initia|
|00004870| 6c 69 7a 65 73 20 69 74 | 20 74 6f 20 74 68 65 20 |lizes it| to the |
|00004880| 65 6d 70 74 79 20 71 75 | 65 75 65 2e 0a 5c 73 6d |empty qu|eue..\sm|
|00004890| 61 6c 6c 73 6b 69 70 0a | 7b 5c 62 66 20 33 2e 20 |allskip.|{\bf 3. |
|000048a0| 5c 6f 70 65 72 61 74 69 | 6f 6e 73 20 7d 0a 5c 73 |\operati|ons }.\s|
|000048b0| 6d 61 6c 6c 73 6b 69 70 | 0a 5c 2b 5c 63 6c 65 61 |mallskip|.\+\clea|
|000048c0| 72 74 61 62 73 20 26 20 | 5c 68 73 6b 69 70 20 31 |rtabs & |\hskip 1|
|000048d0| 2e 38 74 72 75 65 63 6d | 20 26 20 5c 68 73 6b 69 |.8truecm| & \hski|
|000048e0| 70 20 36 2e 35 74 72 75 | 65 63 6d 20 26 5c 63 72 |p 6.5tru|ecm &\cr|
|000048f0| 0a 5c 2b 5c 6f 70 20 4b | 20 20 20 20 6b 65 79 20 |.\+\op K| key |
|00004900| 7b 70 71 5c 5f 69 74 65 | 6d 5c 20 69 74 7d 20 20 |{pq\_ite|m\ it} |
|00004910| 20 20 7b 72 65 74 75 72 | 6e 73 20 74 68 65 20 6b | {retur|ns the k|
|00004920| 65 79 20 6f 66 20 69 74 | 65 6d 20 24 69 74 24 2e |ey of it|em $it$.|
|00004930| 7d 0a 5c 2b 5c 6e 6f 70 | 20 20 20 20 20 20 20 20 |}.\+\nop| |
|00004940| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004950| 20 20 20 7b 5c 70 72 65 | 63 6f 6e 64 20 24 69 74 | {\pre|cond $it|
|00004960| 24 20 69 73 20 61 6e 20 | 69 74 65 6d 20 69 6e 20 |$ is an |item in |
|00004970| 5c 76 61 72 2e 7d 0a 5c | 73 6d 61 6c 6c 73 6b 69 |\var.}.\|smallski|
|00004980| 70 0a 5c 2b 5c 6f 70 20 | 49 20 20 20 20 69 6e 66 |p.\+\op |I inf|
|00004990| 20 7b 70 71 5c 5f 69 74 | 65 6d 5c 20 69 74 7d 20 | {pq\_it|em\ it} |
|000049a0| 20 20 20 7b 72 65 74 75 | 72 6e 73 20 74 68 65 20 | {retu|rns the |
|000049b0| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 20 6f 66 20 69 |informat|ion of i|
|000049c0| 74 65 6d 20 24 69 74 24 | 2e 7d 0a 5c 2b 5c 6e 6f |tem $it$|.}.\+\no|
|000049d0| 70 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |p | |
|000049e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 7b 5c 70 72 | | {\pr|
|000049f0| 65 63 6f 6e 64 20 24 69 | 74 24 20 69 73 20 61 6e |econd $i|t$ is an|
|00004a00| 20 69 74 65 6d 20 69 6e | 20 5c 76 61 72 2e 7d 0a | item in| \var.}.|
|00004a10| 5c 73 6d 61 6c 6c 73 6b | 69 70 0a 5c 2b 5c 6f 70 |\smallsk|ip.\+\op|
|00004a20| 20 70 71 5c 5f 69 74 65 | 6d 20 69 6e 73 65 72 74 | pq\_ite|m insert|
|00004a30| 20 7b 4b 5c 20 6b 2c 49 | 5c 20 69 7d 20 7b 61 64 | {K\ k,I|\ i} {ad|
|00004a40| 64 73 20 61 20 6e 65 77 | 20 69 74 65 6d 20 24 3c |ds a new| item $<|
|00004a50| 6b 2c 69 3e 24 20 74 6f | 20 5c 76 61 72 5c 20 61 |k,i>$ to| \var\ a|
|00004a60| 6e 64 20 72 65 74 75 72 | 6e 73 20 24 69 74 24 2e |nd retur|ns $it$.|
|00004a70| 7d 0a 5c 73 6d 61 6c 6c | 73 6b 69 70 0a 5c 2b 5c |}.\small|skip.\+\|
|00004a80| 6f 70 20 70 71 5c 5f 69 | 74 65 6d 20 66 69 6e 64 |op pq\_i|tem find|
|00004a90| 5c 5f 6d 69 6e 20 7b 7d | 20 20 20 20 20 20 20 7b |\_min {}| {|
|00004aa0| 72 65 74 75 72 6e 73 20 | 61 6e 20 69 74 65 6d 20 |returns |an item |
|00004ab0| 77 69 74 68 20 6d 69 6e | 69 6d 61 6c 20 69 6e 66 |with min|imal inf|
|00004ac0| 6f 72 6d 61 74 69 6f 6e | 7d 0a 5c 2b 5c 6e 6f 70 |ormation|}.\+\nop|
|00004ad0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004ae0| 20 20 20 20 20 20 20 20 | 20 20 20 20 7b 28 6e 69 | | {(ni|
|00004af0| 6c 20 69 66 20 5c 76 61 | 72 5c 20 69 73 20 65 6d |l if \va|r\ is em|
|00004b00| 70 74 79 29 7d 0a 5c 73 | 6d 61 6c 6c 73 6b 69 70 |pty)}.\s|mallskip|
|00004b10| 0a 5c 2b 5c 6f 70 20 76 | 6f 69 64 20 20 20 20 64 |.\+\op v|oid d|
|00004b20| 65 6c 5c 5f 69 74 65 6d | 20 7b 70 71 5c 5f 69 74 |el\_item| {pq\_it|
|00004b30| 65 6d 5c 20 69 74 7d 20 | 0a 20 20 20 20 20 20 20 |em\ it} |. |
|00004b40| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004b50| 20 20 20 20 7b 72 65 6d | 6f 76 65 73 20 74 68 65 | {rem|oves the|
|00004b60| 20 69 74 65 6d 20 24 69 | 74 24 20 66 72 6f 6d 20 | item $i|t$ from |
|00004b70| 5c 76 61 72 2e 7d 0a 5c | 2b 5c 6e 6f 70 20 20 20 |\var.}.\|+\nop |
|00004b80| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004b90| 20 20 7b 5c 70 72 65 63 | 6f 6e 64 20 24 69 74 24 | {\prec|ond $it$|
|00004ba0| 20 69 73 20 61 6e 20 69 | 74 65 6d 20 69 6e 20 5c | is an i|tem in \|
|00004bb0| 76 61 72 2e 7d 0a 5c 73 | 6d 61 6c 6c 73 6b 69 70 |var.}.\s|mallskip|
|00004bc0| 0a 5c 2b 5c 6f 70 20 4b | 20 20 20 20 20 20 20 20 |.\+\op K| |
|00004bd0| 64 65 6c 5c 5f 6d 69 6e | 20 7b 7d 20 0a 20 20 20 |del\_min| {} . |
|00004be0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004bf0| 20 20 20 20 20 20 20 20 | 7b 72 65 6d 6f 76 65 73 | |{removes|
|00004c00| 20 61 6e 20 69 74 65 6d | 20 77 69 74 68 20 6d 69 | an item| with mi|
|00004c10| 6e 69 6d 61 6c 20 69 6e | 66 6f 72 6d 61 74 69 6f |nimal in|formatio|
|00004c20| 6e 7d 0a 5c 2b 5c 6e 6f | 70 20 20 20 20 20 20 20 |n}.\+\no|p |
|00004c30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 7b 66 | | {f|
|00004c40| 72 6f 6d 20 5c 76 61 72 | 5c 20 61 6e 64 20 72 65 |rom \var|\ and re|
|00004c50| 74 75 72 6e 73 20 69 74 | 73 20 6b 65 79 2e 7d 0a |turns it|s key.}.|
|00004c60| 5c 2b 5c 6e 6f 70 20 20 | 20 20 20 20 20 20 20 20 |\+\nop | |
|00004c70| 20 20 20 20 20 20 20 20 | 20 20 20 7b 5c 70 72 65 | | {\pre|
|00004c80| 63 6f 6e 64 20 5c 76 61 | 72 5c 20 69 73 20 6e 6f |cond \va|r\ is no|
|00004c90| 74 20 65 6d 70 74 79 2e | 7d 0a 5c 73 6d 61 6c 6c |t empty.|}.\small|
|00004ca0| 73 6b 69 70 0a 5c 2b 5c | 6f 70 20 70 71 5c 5f 69 |skip.\+\|op pq\_i|
|00004cb0| 74 65 6d 20 64 65 63 72 | 65 61 73 65 5c 5f 69 6e |tem decr|ease\_in|
|00004cc0| 66 20 7b 70 71 5c 5f 69 | 74 65 6d 5c 20 69 74 2c |f {pq\_i|tem\ it,|
|00004cd0| 49 5c 20 69 7d 20 0a 20 | 20 20 20 20 20 20 20 20 |I\ i} . | |
|00004ce0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004cf0| 20 20 7b 6d 61 6b 65 73 | 20 69 20 74 68 65 20 6e | {makes| i the n|
|00004d00| 65 77 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 20 6f |ew infor|mation o|
|00004d10| 66 20 69 74 65 6d 20 24 | 69 74 24 7d 0a 5c 2b 5c |f item $|it$}.\+\|
|00004d20| 6e 6f 70 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |nop | |
|00004d30| 20 20 20 20 20 20 20 20 | 7b 5c 70 72 65 63 6f 6e | |{\precon|
|00004d40| 64 20 24 69 74 24 20 69 | 73 20 61 6e 20 69 74 65 |d $it$ i|s an ite|
|00004d50| 6d 20 69 6e 20 5c 76 61 | 72 5c 20 61 6e 64 20 24 |m in \va|r\ and $|
|00004d60| 69 24 7d 0a 5c 2b 5c 6e | 6f 70 20 20 20 20 20 20 |i$}.\+\n|op |
|00004d70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 7b | | {|
|00004d80| 69 73 20 6e 6f 74 20 6c | 61 72 67 65 72 20 74 68 |is not l|arger th|
|00004d90| 65 6e 20 24 69 6e 66 28 | 69 74 29 24 2e 7d 0a 5c |en $inf(|it)$.}.\|
|00004da0| 73 6d 61 6c 6c 73 6b 69 | 70 0a 5c 2b 5c 6f 70 20 |smallski|p.\+\op |
|00004db0| 76 6f 69 64 20 63 6c 65 | 61 72 20 7b 7d 20 20 20 |void cle|ar {} |
|00004dc0| 20 20 20 20 20 0a 20 20 | 20 20 20 20 20 20 20 20 | . | |
|00004dd0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004de0| 20 7b 6d 61 6b 65 73 20 | 5c 76 61 72 5c 20 74 68 | {makes |\var\ th|
|00004df0| 65 20 65 6d 70 74 79 20 | 70 72 69 6f 72 69 74 79 |e empty |priority|
|00004e00| 20 71 75 65 75 65 20 7d | 0a 5c 73 6d 61 6c 6c 73 | queue }|.\smalls|
|00004e10| 6b 69 70 0a 5c 2b 5c 6f | 70 20 62 6f 6f 6c 20 65 |kip.\+\o|p bool e|
|00004e20| 6d 70 74 79 20 7b 7d 20 | 0a 20 20 20 20 20 20 20 |mpty {} |. |
|00004e30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004e40| 20 20 20 20 7b 72 65 74 | 75 72 6e 73 20 74 72 75 | {ret|urns tru|
|00004e50| 65 2c 20 69 66 20 5c 76 | 61 72 5c 20 69 73 20 65 |e, if \v|ar\ is e|
|00004e60| 6d 70 74 79 2c 20 66 61 | 6c 73 65 20 6f 74 68 65 |mpty, fa|lse othe|
|00004e70| 72 77 69 73 65 7d 0a 5c | 73 6d 61 6c 6c 73 6b 69 |rwise}.\|smallski|
|00004e80| 70 0a 5c 2b 5c 6f 70 20 | 69 6e 74 20 20 73 69 7a |p.\+\op |int siz|
|00004e90| 65 20 20 7b 7d 0a 20 20 | 20 20 20 20 20 20 20 20 |e {}. | |
|00004ea0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004eb0| 20 7b 72 65 74 75 72 6e | 73 20 74 68 65 20 73 69 | {return|s the si|
|00004ec0| 7a 65 20 6f 66 20 5c 76 | 61 72 2e 7d 0a 5c 73 6d |ze of \v|ar.}.\sm|
|00004ed0| 61 6c 6c 73 6b 69 70 0a | 50 72 69 6f 72 69 74 79 |allskip.|Priority|
|00004ee0| 20 71 75 65 75 65 73 20 | 61 72 65 20 69 6d 70 6c | queues |are impl|
|00004ef0| 65 6d 65 6e 74 65 64 20 | 62 79 20 46 69 62 6f 6e |emented |by Fibon|
|00004f00| 61 63 63 69 20 48 65 61 | 70 73 2e 20 4f 70 65 72 |acci Hea|ps. Oper|
|00004f10| 61 74 69 6f 6e 73 20 69 | 6e 73 65 72 74 2c 20 0a |ations i|nsert, .|
|00004f20| 64 65 6c 5c 5f 69 74 65 | 6d 2c 20 64 65 6c 5c 5f |del\_ite|m, del\_|
|00004f30| 6d 69 6e 20 74 61 6b 65 | 20 74 69 6d 65 20 24 4f |min take| time $O|
|00004f40| 28 5c 6c 6f 67 20 6e 29 | 24 2c 20 66 69 6e 64 5c |(\log n)|$, find\|
|00004f50| 5f 6d 69 6e 2c 20 64 65 | 63 72 65 61 73 65 5c 5f |_min, de|crease\_|
|00004f60| 69 6e 66 2c 20 0a 6b 65 | 79 2c 20 69 6e 66 2c 20 |inf, .ke|y, inf, |
|00004f70| 65 6d 70 74 79 20 74 61 | 6b 65 20 74 69 6d 65 20 |empty ta|ke time |
|00004f80| 24 4f 28 31 29 24 20 61 | 6e 64 20 63 6c 65 61 72 |$O(1)$ a|nd clear|
|00004f90| 20 74 61 6b 65 73 20 74 | 69 6d 65 20 24 4f 28 6e | takes t|ime $O(n|
|00004fa0| 29 24 2c 20 77 68 65 72 | 65 20 24 6e 24 20 69 73 |)$, wher|e $n$ is|
|00004fb0| 20 74 68 65 20 0a 73 69 | 7a 65 20 6f 66 20 74 68 | the .si|ze of th|
|00004fc0| 65 20 71 75 65 75 65 2e | 20 54 68 65 20 73 70 61 |e queue.| The spa|
|00004fd0| 63 65 20 72 65 71 75 69 | 72 65 6d 65 6e 74 20 69 |ce requi|rement i|
|00004fe0| 73 20 24 4f 28 6e 29 24 | 2e 0a 5c 76 66 69 6c 6c |s $O(n)$|..\vfill|
|00004ff0| 0a 5c 6c 69 6e 65 7b 5c | 68 72 75 6c 65 66 69 6c |.\line{\|hrulefil|
|00005000| 6c 5c 20 7b 5c 62 66 20 | 46 69 67 75 72 65 20 31 |l\ {\bf |Figure 1|
|00005010| 7d 3a 20 54 68 65 20 73 | 70 65 63 69 66 69 63 61 |}: The s|pecifica|
|00005020| 74 69 6f 6e 20 6f 66 20 | 70 72 69 6f 72 69 74 79 |tion of |priority|
|00005030| 20 71 75 65 75 65 73 2e | 5c 20 5c 68 72 75 6c 65 | queues.|\ \hrule|
|00005040| 66 69 6c 6c 7d 0a 7d 0a | 0a 5c 76 66 69 6c 6c 5c |fill}.}.|.\vfill\|
|00005050| 65 6a 65 63 74 0a 0a 5c | 62 69 67 73 6b 69 70 0a |eject..\|bigskip.|
|00005060| 7b 5c 6d 61 67 6f 6e 65 | 20 45 78 61 6d 70 6c 65 |{\magone| Example|
|00005070| 20 33 3a 20 50 61 72 74 | 69 74 69 6f 6e 73 20 6f | 3: Part|itions o|
|00005080| 72 20 44 69 73 6a 6f 69 | 6e 74 20 53 65 74 73 7d |r Disjoi|nt Sets}|
|00005090| 0a 0a 49 6e 20 74 68 69 | 73 20 65 78 61 6d 70 6c |..In thi|s exampl|
|000050a0| 65 20 77 65 20 64 69 73 | 63 75 73 73 20 70 61 72 |e we dis|cuss par|
|000050b0| 74 69 74 69 6f 6e 73 20 | 6f 66 20 66 69 6e 69 74 |titions |of finit|
|000050c0| 65 20 73 65 74 73 2c 20 | 66 72 65 71 75 65 6e 74 |e sets, |frequent|
|000050d0| 6c 79 20 63 61 6c 6c 65 | 64 20 74 68 65 20 0a 75 |ly calle|d the .u|
|000050e0| 6e 69 6f 6e 2d 66 69 6e | 64 20 70 72 6f 62 6c 65 |nion-fin|d proble|
|000050f0| 6d 2e 20 20 41 6e 20 61 | 70 70 6c 69 63 61 74 69 |m. An a|pplicati|
|00005100| 6f 6e 20 6f 66 20 70 61 | 72 74 69 74 69 6f 6e 73 |on of pa|rtitions|
|00005110| 20 69 73 20 73 68 6f 77 | 6e 20 69 6e 20 70 72 6f | is show|n in pro|
|00005120| 67 72 61 6d 7e 34 20 6f | 66 20 0a 73 65 63 74 69 |gram~4 o|f .secti|
|00005130| 6f 6e 7e 49 49 49 2e 20 | 20 0a 0a 41 6e 20 6f 62 |on~III. | ..An ob|
|00005140| 6a 65 63 74 20 24 50 24 | 20 6f 66 20 74 79 70 65 |ject $P$| of type|
|00005150| 20 7b 5c 73 6c 20 70 61 | 72 74 69 74 69 6f 6e 7d | {\sl pa|rtition}|
|00005160| 20 63 6f 6e 73 69 73 74 | 73 20 6f 66 20 61 20 66 | consist|s of a f|
|00005170| 69 6e 69 74 65 20 73 65 | 74 0a 6f 66 20 70 61 72 |inite se|t.of par|
|00005180| 74 69 74 69 6f 6e 5c 5f | 69 74 65 6d 73 20 61 6e |tition\_|items an|
|00005190| 64 20 61 20 70 61 72 74 | 69 74 69 6f 6e 20 6f 66 |d a part|ition of|
|000051a0| 20 74 68 69 73 20 73 65 | 74 20 69 6e 74 6f 20 62 | this se|t into b|
|000051b0| 6c 6f 63 6b 73 2e 0a 54 | 68 65 20 64 65 63 6c 61 |locks..T|he decla|
|000051c0| 72 61 74 69 6f 6e 20 24 | 70 61 72 74 69 74 69 6f |ration $|partitio|
|000051d0| 6e 24 20 24 50 24 20 69 | 6e 74 72 6f 64 75 63 65 |n$ $P$ i|ntroduce|
|000051e0| 73 20 24 50 24 20 61 73 | 20 74 68 65 20 6e 61 6d |s $P$ as| the nam|
|000051f0| 65 20 6f 66 20 61 0a 70 | 61 72 74 69 74 69 6f 6e |e of a.p|artition|
|00005200| 20 61 6e 64 20 69 6e 69 | 74 69 61 6c 69 7a 65 73 | and ini|tializes|
|00005210| 20 69 74 20 74 6f 20 74 | 68 65 20 65 6d 70 74 79 | it to t|he empty|
|00005220| 20 70 61 72 74 69 74 69 | 6f 6e 2e 0a 54 68 65 72 | partiti|on..Ther|
|00005230| 65 20 61 72 65 20 74 68 | 72 65 65 20 6f 70 65 72 |e are th|ree oper|
|00005240| 61 74 69 6f 6e 73 2e 0a | 5c 6d 65 64 73 6b 69 70 |ations..|\medskip|
|00005250| 0a 5c 73 65 74 74 61 62 | 73 5c 2b 24 70 61 72 74 |.\settab|s\+$part|
|00005260| 69 74 69 6f 6e 5c 5f 69 | 74 65 6d 24 5c 71 75 61 |ition\_i|tem$\qua|
|00005270| 64 20 26 20 24 50 2e 75 | 6e 69 6f 6e 5c 5f 62 6c |d & $P.u|nion\_bl|
|00005280| 6f 63 6b 73 28 70 61 72 | 74 69 74 69 6f 6e 5c 5f |ocks(par|tition\_|
|00005290| 69 74 65 6d 5c 20 70 2c | 71 29 24 5c 71 75 61 64 |item\ p,|q)$\quad|
|000052a0| 20 26 20 72 65 74 75 72 | 6e 73 20 61 20 6e 65 77 | & retur|ns a new|
|000052b0| 20 70 61 72 74 69 74 69 | 6f 6e 5c 5f 69 74 65 6d | partiti|on\_item|
|000052c0| 20 24 69 74 24 20 61 6e | 64 20 61 64 64 73 20 74 | $it$ an|d adds t|
|000052d0| 68 65 20 62 6c 6f 63 6b | 20 24 5c 7b 69 74 5c 7d |he block| $\{it\}|
|000052e0| 24 20 74 6f 20 74 68 65 | 20 70 61 72 74 69 74 69 |$ to the| partiti|
|000052f0| 6f 6e 20 24 50 24 5c 63 | 72 0a 5c 2b 24 70 61 72 |on $P$\c|r.\+$par|
|00005300| 74 69 74 69 6f 6e 5c 5f | 69 74 65 6d 24 26 20 24 |tition\_|item$& $|
|00005310| 50 2e 6d 61 6b 65 5c 5f | 62 6c 6f 63 6b 28 29 24 |P.make\_|block()$|
|00005320| 26 20 72 65 74 75 72 6e | 73 20 61 20 6e 65 77 20 |& return|s a new |
|00005330| 70 61 72 74 69 74 69 6f | 6e 5c 5f 69 74 65 6d 20 |partitio|n\_item |
|00005340| 24 69 74 24 5c 63 72 0a | 5c 2b 20 20 20 20 20 20 |$it$\cr.|\+ |
|00005350| 20 20 20 20 20 20 20 20 | 20 20 20 26 20 20 20 20 | | & |
|00005360| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 26 20 | | & |
|00005370| 61 6e 64 20 61 64 64 73 | 20 74 68 65 20 62 6c 6f |and adds| the blo|
|00005380| 63 6b 20 24 5c 7b 69 74 | 5c 7d 24 20 74 6f 20 74 |ck $\{it|\}$ to t|
|00005390| 68 65 5c 63 72 0a 5c 2b | 20 20 20 20 20 20 20 20 |he\cr.\+| |
|000053a0| 20 20 20 20 20 20 20 20 | 20 26 20 20 20 20 20 20 | | & |
|000053b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 26 20 70 61 | | & pa|
|000053c0| 72 74 69 74 69 6f 6e 20 | 24 50 24 2e 5c 63 72 0a |rtition |$P$.\cr.|
|000053d0| 5c 6d 65 64 73 6b 69 70 | 0a 5c 2b 24 69 6e 74 24 |\medskip|.\+$int$|
|000053e0| 26 20 24 50 2e 73 61 6d | 65 5c 5f 62 6c 6f 63 6b |& $P.sam|e\_block|
|000053f0| 28 70 61 72 74 69 74 69 | 6f 6e 5c 5f 69 74 65 6d |(partiti|on\_item|
|00005400| 5c 20 70 2c 71 29 24 26 | 20 72 65 74 75 72 6e 73 |\ p,q)$&| returns|
|00005410| 20 74 72 75 65 20 69 66 | 20 24 70 24 20 61 6e 64 | true if| $p$ and|
|00005420| 20 24 71 24 20 62 65 6c | 6f 6e 67 20 74 6f 5c 63 | $q$ bel|ong to\c|
|00005430| 72 0a 5c 2b 09 20 20 09 | 20 20 20 26 09 09 20 20 |r.\+. .| &.. |
|00005440| 20 20 20 20 26 20 74 68 | 65 20 73 61 6d 65 20 62 | & th|e same b|
|00005450| 6c 6f 63 6b 20 6f 66 20 | 74 68 65 20 70 61 72 74 |lock of |the part|
|00005460| 69 74 69 6f 6e 20 24 50 | 24 2e 5c 63 72 0a 5c 6d |ition $P|$.\cr.\m|
|00005470| 65 64 73 6b 69 70 0a 5c | 2b 24 76 6f 69 64 24 26 |edskip.\|+$void$&|
|00005480| 20 24 50 2e 75 6e 69 6f | 6e 5c 5f 62 6c 6f 63 6b | $P.unio|n\_block|
|00005490| 73 28 70 61 72 74 69 74 | 69 6f 6e 5c 5f 69 74 65 |s(partit|ion\_ite|
|000054a0| 6d 5c 20 70 2c 71 29 24 | 26 20 75 6e 69 74 65 73 |m\ p,q)$|& unites|
|000054b0| 20 74 68 65 20 62 6c 6f | 63 6b 73 20 6f 66 20 24 | the blo|cks of $|
|000054c0| 50 24 20 63 6f 6e 74 61 | 69 6e 69 6e 67 5c 63 72 |P$ conta|ining\cr|
|000054d0| 0a 5c 2b 09 09 20 20 20 | 26 09 09 20 20 20 20 20 |.\+.. |&.. |
|000054e0| 20 26 20 69 74 65 6d 73 | 20 24 70 24 20 61 6e 64 | & items| $p$ and|
|000054f0| 20 24 71 24 2e 5c 63 72 | 0a 5c 63 6c 65 61 72 74 | $q$.\cr|.\cleart|
|00005500| 61 62 73 0a 5c 6d 65 64 | 73 6b 69 70 0a 57 65 20 |abs.\med|skip.We |
|00005510| 77 61 6e 74 20 74 6f 20 | 73 74 72 65 73 73 20 74 |want to |stress t|
|00005520| 68 61 74 20 74 68 65 20 | 6d 61 6b 65 5c 5f 62 6c |hat the |make\_bl|
|00005530| 6f 63 6b 2d 6f 70 65 72 | 61 74 69 6f 6e 20 68 61 |ock-oper|ation ha|
|00005540| 73 20 6e 6f 20 70 61 72 | 61 6d 65 74 65 72 2e 0a |s no par|ameter..|
|00005550| 49 74 20 69 73 20 6e 6f | 74 20 67 69 76 65 6e 20 |It is no|t given |
|00005560| 61 6e 20 6f 62 6a 65 63 | 74 20 77 68 69 63 68 20 |an objec|t which |
|00005570| 69 74 20 69 73 20 73 75 | 70 70 6f 73 65 64 20 74 |it is su|pposed t|
|00005580| 6f 20 61 64 64 20 74 6f | 20 74 68 65 0a 70 61 72 |o add to| the.par|
|00005590| 74 69 74 69 6f 6e 20 24 | 50 24 2c 20 62 75 74 20 |tition $|P$, but |
|000055a0| 74 68 65 20 6f 70 65 72 | 61 74 69 6f 6e 20 69 74 |the oper|ation it|
|000055b0| 73 65 6c 66 20 63 68 6f | 6f 73 65 73 20 61 6e 20 |self cho|oses an |
|000055c0| 69 74 65 6d 20 24 69 74 | 24 2c 20 0a 72 65 74 75 |item $it|$, .retu|
|000055d0| 72 6e 73 20 69 74 20 61 | 6e 64 20 61 64 64 73 20 |rns it a|nd adds |
|000055e0| 74 68 65 20 62 6c 6f 63 | 6b 20 24 5c 7b 69 74 5c |the bloc|k $\{it\|
|000055f0| 7d 24 20 74 6f 20 74 68 | 65 20 70 61 72 74 69 74 |}$ to th|e partit|
|00005600| 69 6f 6e 20 24 50 24 2e | 0a 54 68 65 20 75 73 65 |ion $P$.|.The use|
|00005610| 72 20 68 61 73 20 6e 6f | 20 69 64 65 61 20 77 68 |r has no| idea wh|
|00005620| 61 74 20 24 69 74 24 20 | 69 73 20 61 6e 64 20 68 |at $it$ |is and h|
|00005630| 65 20 64 6f 65 73 20 6e | 6f 74 20 6e 65 65 64 20 |e does n|ot need |
|00005640| 74 6f 20 6b 6e 6f 77 2e | 0a 54 68 65 20 6f 6e 6c |to know.|.The onl|
|00005650| 79 20 74 68 69 6e 67 2c | 20 74 68 61 74 20 69 73 |y thing,| that is|
|00005660| 20 69 6d 70 6f 72 74 61 | 6e 74 20 74 6f 20 68 69 | importa|nt to hi|
|00005670| 6d 2c 20 69 73 20 74 68 | 65 20 70 61 72 74 69 74 |m, is th|e partit|
|00005680| 69 6f 6e 20 6f 66 0a 74 | 68 65 20 69 74 65 6d 73 |ion of.t|he items|
|00005690| 20 69 6e 74 6f 20 62 6c | 6f 63 6b 73 2e 20 54 68 | into bl|ocks. Th|
|000056a0| 69 73 20 75 73 61 67 65 | 20 6f 66 20 69 74 65 6d |is usage| of item|
|000056b0| 73 20 69 73 20 73 69 6d | 69 6c 61 72 20 74 6f 20 |s is sim|ilar to |
|000056c0| 74 68 65 20 75 73 61 67 | 65 20 0a 6f 66 20 61 74 |the usag|e .of at|
|000056d0| 6f 6d 73 20 69 6e 20 53 | 45 54 4c 2e 0a 0a 7b 5c |oms in S|ETL...{\|
|000056e0| 62 66 20 52 65 6d 61 72 | 6b 7d 3a 20 49 6e 20 74 |bf Remar|k}: In t|
|000056f0| 68 65 20 74 65 78 74 20 | 62 6f 6f 6b 73 20 28 5b |he text |books ([|
|00005700| 41 48 55 38 33 5d 2c 20 | 5b 4d 38 34 5d 2c 20 5b |AHU83], |[M84], [|
|00005710| 54 38 33 5d 29 20 6d 61 | 6b 65 5c 5f 62 6c 6f 63 |T83]) ma|ke\_bloc|
|00005720| 6b 0a 74 61 6b 65 73 20 | 61 6e 20 69 74 65 6d 20 |k.takes |an item |
|00005730| 61 73 20 69 6e 70 75 74 | 20 61 6e 64 20 74 68 65 |as input| and the|
|00005740| 72 65 66 6f 72 65 20 74 | 68 65 20 72 65 6d 61 72 |refore t|he remar|
|00005750| 6b 20 6d 61 64 65 20 69 | 6e 20 74 68 65 20 70 72 |k made i|n the pr|
|00005760| 69 6f 72 69 74 79 0a 71 | 75 65 75 65 20 65 78 61 |iority.q|ueue exa|
|00005770| 6d 70 6c 65 20 61 70 70 | 6c 69 65 73 20 68 65 72 |mple app|lies her|
|00005780| 65 20 61 6c 73 6f 2e 20 | 57 65 20 66 65 65 6c 20 |e also. |We feel |
|00005790| 74 68 61 74 20 74 68 65 | 20 73 70 65 63 69 66 69 |that the| specifi|
|000057a0| 63 61 74 69 6f 6e 20 67 | 69 76 65 6e 0a 61 62 6f |cation g|iven.abo|
|000057b0| 76 65 20 69 73 20 6d 6f | 72 65 20 6e 61 74 75 72 |ve is mo|re natur|
|000057c0| 61 6c 2e 0a 0a 41 63 63 | 65 73 73 20 62 79 20 70 |al...Acc|ess by p|
|000057d0| 6f 73 69 74 69 6f 6e 20 | 69 6e 73 74 65 61 64 20 |osition |instead |
|000057e0| 6f 66 20 6b 65 79 20 69 | 73 20 61 62 75 6e 64 61 |of key i|s abunda|
|000057f0| 6e 74 20 69 6e 20 74 68 | 65 20 64 65 73 69 67 6e |nt in th|e design|
|00005800| 20 6f 66 0a 65 66 66 69 | 63 69 65 6e 74 20 64 61 | of.effi|cient da|
|00005810| 74 61 20 73 74 72 75 63 | 74 75 72 65 73 3b 20 65 |ta struc|tures; e|
|00005820| 2e 67 2e 2c 20 6c 69 73 | 74 73 20 61 72 65 20 61 |.g., lis|ts are a|
|00005830| 63 63 65 73 73 65 64 20 | 62 79 20 70 6f 73 69 74 |ccessed |by posit|
|00005840| 69 6f 6e 2c 0a 61 6c 6c | 20 6f 70 65 72 61 74 69 |ion,.all| operati|
|00005850| 6f 6e 73 20 69 6e 20 74 | 68 65 20 75 6e 69 6f 6e |ons in t|he union|
|00005860| 2d 66 69 6e 64 20 70 72 | 6f 62 6c 65 6d 20 75 73 |-find pr|oblem us|
|00005870| 65 20 61 63 63 65 73 73 | 20 62 79 0a 70 6f 73 69 |e access| by.posi|
|00005880| 74 69 6f 6e 2c 20 74 68 | 65 20 64 65 63 72 65 61 |tion, th|e decrea|
|00005890| 73 65 2d 69 6e 66 20 6f | 70 65 72 61 74 69 6f 6e |se-inf o|peration|
|000058a0| 20 69 6e 20 70 72 69 6f | 72 69 74 79 20 71 75 65 | in prio|rity que|
|000058b0| 75 65 73 20 69 73 0a 62 | 61 73 65 64 20 6f 6e 20 |ues is.b|ased on |
|000058c0| 69 74 2c 20 61 6e 64 20 | 66 69 6e 67 65 72 73 20 |it, and |fingers |
|000058d0| 69 6e 20 66 69 6e 67 65 | 72 20 74 72 65 65 73 20 |in finge|r trees |
|000058e0| 61 72 65 20 70 6f 73 69 | 74 69 6f 6e 73 2e 0a 54 |are posi|tions..T|
|000058f0| 68 75 73 20 74 68 65 20 | 70 6f 73 69 74 69 6f 6e |hus the |position|
|00005900| 20 63 6f 6e 63 65 70 74 | 20 69 73 20 63 72 75 63 | concept| is cruc|
|00005910| 69 61 6c 20 66 6f 72 20 | 74 68 65 20 64 65 73 69 |ial for |the desi|
|00005920| 67 6e 20 6f 66 20 65 66 | 66 69 63 69 65 6e 74 0a |gn of ef|ficient.|
|00005930| 64 61 74 61 20 73 74 72 | 75 63 74 75 72 65 73 2e |data str|uctures.|
|00005940| 20 49 6e 20 4c 45 44 41 | 20 77 65 20 75 73 65 20 | In LEDA| we use |
|00005950| 69 74 65 6d 73 20 61 73 | 20 61 6e 20 61 62 73 74 |items as| an abst|
|00005960| 72 61 63 74 69 6f 6e 20 | 6f 66 20 70 6f 73 69 74 |raction |of posit|
|00005970| 69 6f 6e 73 2e 0a 4d 61 | 6e 79 20 6f 70 65 72 61 |ions..Ma|ny opera|
|00005980| 74 69 6f 6e 73 20 74 61 | 6b 65 20 69 74 65 6d 73 |tions ta|ke items|
|00005990| 20 61 73 20 61 72 67 75 | 6d 65 6e 74 73 20 6f 72 | as argu|ments or|
|000059a0| 20 72 65 74 75 72 6e 20 | 69 74 65 6d 73 20 61 73 | return |items as|
|000059b0| 20 72 65 73 75 6c 74 73 | 2e 20 0a 54 68 65 20 65 | results|. .The e|
|000059c0| 78 61 6d 70 6c 65 73 20 | 67 69 76 65 6e 20 61 62 |xamples |given ab|
|000059d0| 6f 76 65 20 73 68 6f 77 | 20 74 68 61 74 20 74 68 |ove show| that th|
|000059e0| 65 20 69 74 65 6d 20 63 | 6f 6e 63 65 70 74 20 6c |e item c|oncept l|
|000059f0| 65 61 64 73 20 74 6f 20 | 6e 61 74 75 72 61 6c 20 |eads to |natural |
|00005a00| 0a 73 70 65 63 69 66 69 | 63 61 74 69 6f 6e 73 20 |.specifi|cations |
|00005a10| 6f 66 20 64 61 74 61 20 | 74 79 70 65 73 2e 20 4d |of data |types. M|
|00005a20| 6f 72 65 20 65 78 61 6d | 70 6c 65 73 20 63 61 6e |ore exam|ples can|
|00005a30| 20 62 65 20 66 6f 75 6e | 64 20 69 6e 20 5b 4e 39 | be foun|d in [N9|
|00005a40| 30 5d 2e 0a 0a 0a 5c 62 | 69 67 73 6b 69 70 0a 5c |0]....\b|igskip.\|
|00005a50| 62 69 67 73 6b 69 70 0a | 7b 5c 6d 61 67 6f 6e 65 |bigskip.|{\magone|
|00005a60| 62 66 20 49 49 49 2e 20 | 47 72 61 70 68 73 7d 0a |bf III. |Graphs}.|
|00005a70| 0a 47 72 61 70 68 20 61 | 6c 67 6f 72 69 74 68 6d |.Graph a|lgorithm|
|00005a80| 73 20 61 72 65 20 61 20 | 70 72 69 6d 65 20 65 78 |s are a |prime ex|
|00005a90| 61 6d 70 6c 65 20 6f 66 | 20 63 6f 6d 62 69 6e 61 |ample of| combina|
|00005aa0| 74 6f 72 69 61 6c 0a 63 | 6f 6d 70 75 74 69 6e 67 |torial.c|omputing|
|00005ab0| 2e 20 4c 45 44 41 20 63 | 6f 6e 74 61 69 6e 73 20 |. LEDA c|ontains |
|00005ac0| 73 65 76 65 72 61 6c 20 | 67 72 61 70 68 20 74 79 |several |graph ty|
|00005ad0| 70 65 73 20 61 6e 64 20 | 64 61 74 61 20 74 79 70 |pes and |data typ|
|00005ae0| 65 73 20 72 65 6c 61 74 | 65 64 20 77 69 74 68 0a |es relat|ed with.|
|00005af0| 67 72 61 70 68 73 20 61 | 6c 6c 6f 77 69 6e 67 20 |graphs a|llowing |
|00005b00| 65 6c 65 67 61 6e 74 20 | 61 6e 64 20 65 66 66 69 |elegant |and effi|
|00005b10| 63 69 65 6e 74 20 69 6d | 70 6c 65 6d 65 6e 74 61 |cient im|plementa|
|00005b20| 74 69 6f 6e 73 20 6f 66 | 20 67 72 61 70 68 0a 61 |tions of| graph.a|
|00005b30| 6e 64 20 6e 65 74 77 6f | 72 6b 20 61 6c 67 6f 72 |nd netwo|rk algor|
|00005b40| 69 74 68 6d 73 2e 20 0a | 0a 24 67 72 61 70 68 24 |ithms. .|.$graph$|
|00005b50| 20 69 73 20 74 68 65 20 | 64 61 74 61 20 74 79 70 | is the |data typ|
|00005b60| 65 20 6f 66 20 64 69 72 | 65 63 74 65 64 20 67 72 |e of dir|ected gr|
|00005b70| 61 70 68 73 2e 0a 49 74 | 20 70 72 6f 76 69 64 65 |aphs..It| provide|
|00005b80| 73 20 6f 70 65 72 61 74 | 69 6f 6e 73 20 66 6f 72 |s operat|ions for|
|00005b90| 20 74 68 65 20 75 70 64 | 61 74 69 6e 67 20 28 69 | the upd|ating (i|
|00005ba0| 6e 73 65 72 74 69 6e 67 | 20 61 6e 64 20 64 65 6c |nserting| and del|
|00005bb0| 65 74 69 6e 67 20 6e 6f | 64 65 73 0a 61 6e 64 20 |eting no|des.and |
|00005bc0| 65 64 67 65 73 29 20 61 | 6e 64 20 61 63 63 65 73 |edges) a|nd acces|
|00005bd0| 73 69 6e 67 20 69 6e 74 | 65 72 6e 61 6c 20 69 6e |sing int|ernal in|
|00005be0| 66 6f 72 6d 61 74 69 6f | 6e 73 20 28 6e 75 6d 62 |formatio|ns (numb|
|00005bf0| 65 72 20 6f 66 20 6e 6f | 64 65 73 20 6f 72 20 65 |er of no|des or e|
|00005c00| 64 67 65 73 2c 0a 6f 75 | 74 2d 20 61 6e 64 20 69 |dges,.ou|t- and i|
|00005c10| 6e 64 65 67 72 65 65 20 | 6f 66 20 6e 6f 64 65 73 |ndegree |of nodes|
|00005c20| 2c 20 65 6e 64 70 6f 69 | 6e 74 73 20 6f 66 20 65 |, endpoi|nts of e|
|00005c30| 64 67 65 73 2c 20 6c 69 | 73 74 20 6f 66 20 65 64 |dges, li|st of ed|
|00005c40| 67 65 73 20 61 64 6a 61 | 63 65 6e 74 0a 74 6f 20 |ges adja|cent.to |
|00005c50| 61 20 67 69 76 65 6e 20 | 6e 6f 64 65 2c 20 5c 64 |a given |node, \d|
|00005c60| 6f 74 73 29 20 6f 66 20 | 64 69 72 65 63 74 65 64 |ots) of |directed|
|00005c70| 20 67 72 61 70 68 73 2e | 20 46 75 72 74 68 65 72 | graphs.| Further|
|00005c80| 6d 6f 72 65 20 74 68 65 | 72 65 20 61 72 65 0a 73 |more the|re are.s|
|00005c90| 65 76 65 72 61 6c 20 69 | 74 65 72 61 74 69 6f 6e |everal i|teration|
|00005ca0| 20 73 74 61 74 65 6d 65 | 6e 74 73 20 74 68 61 74 | stateme|nts that|
|00005cb0| 20 63 61 6e 20 62 65 20 | 75 73 65 64 20 74 6f 20 | can be |used to |
|00005cc0| 69 74 65 72 61 74 65 20 | 6f 76 65 72 20 74 68 65 |iterate |over the|
|00005cd0| 0a 6e 6f 64 65 73 20 61 | 6e 64 20 65 64 67 65 73 |.nodes a|nd edges|
|00005ce0| 20 28 7b 5c 62 66 20 66 | 6f 72 5c 5f 61 6c 6c 5c | ({\bf f|or\_all\|
|00005cf0| 5f 6e 6f 64 65 73 7d 2c | 20 7b 5c 62 66 20 66 6f |_nodes},| {\bf fo|
|00005d00| 72 5c 5f 61 6c 6c 5c 5f | 65 64 67 65 73 7d 2c 20 |r\_all\_|edges}, |
|00005d10| 5c 64 6f 74 73 29 2e 0a | 0a 50 72 6f 67 72 61 6d |\dots)..|.Program|
|00005d20| 7e 32 20 67 69 76 65 73 | 20 61 20 73 68 6f 72 74 |~2 gives| a short|
|00005d30| 20 64 65 6d 6f 6e 73 74 | 72 61 74 69 6f 6e 20 6f | demonst|ration o|
|00005d40| 66 20 73 6f 6d 65 20 67 | 72 61 70 68 20 6f 70 65 |f some g|raph ope|
|00005d50| 72 61 74 69 6f 6e 73 0a | 61 73 20 74 68 65 79 20 |rations.|as they |
|00005d60| 61 72 65 20 75 73 65 64 | 20 74 6f 20 74 65 73 74 |are used| to test|
|00005d70| 20 61 20 64 69 72 65 63 | 74 65 64 20 67 72 61 70 | a direc|ted grap|
|00005d80| 68 20 24 47 24 20 66 6f | 72 20 61 63 79 63 6c 69 |h $G$ fo|r acycli|
|00005d90| 63 69 74 79 2e 0a 54 68 | 65 20 61 6c 67 6f 72 69 |city..Th|e algori|
|00005da0| 74 68 6d 20 75 73 65 73 | 20 74 68 65 20 64 61 74 |thm uses| the dat|
|00005db0| 61 20 74 79 70 65 73 20 | 24 67 72 61 70 68 24 20 |a types |$graph$ |
|00005dc0| 61 6e 64 20 24 6e 6f 64 | 65 5c 5f 73 65 74 24 20 |and $nod|e\_set$ |
|00005dd0| 77 68 6f 73 65 20 73 70 | 65 63 69 66 69 63 61 74 |whose sp|ecificat|
|00005de0| 69 6f 6e 73 0a 61 72 65 | 20 63 6f 6e 74 61 69 6e |ions.are| contain|
|00005df0| 65 64 20 69 6e 20 74 68 | 65 20 68 65 61 64 65 72 |ed in th|e header|
|00005e00| 20 66 69 6c 65 20 60 60 | 4c 45 44 41 2f 67 72 61 | file ``|LEDA/gra|
|00005e10| 70 68 2e 68 27 27 20 77 | 68 69 63 68 20 69 73 20 |ph.h'' w|hich is |
|00005e20| 69 6e 63 6c 75 64 65 64 | 20 69 6e 20 6c 69 6e 65 |included| in line|
|00005e30| 20 31 2e 0a 49 6e 20 6c | 69 6e 65 7e 34 20 61 20 | 1..In l|ine~4 a |
|00005e40| 6e 6f 64 65 20 73 65 74 | 20 24 7a 65 72 6f 24 20 |node set| $zero$ |
|00005e50| 66 6f 72 20 74 68 65 20 | 6e 6f 64 65 73 20 6f 66 |for the |nodes of|
|00005e60| 20 67 72 61 70 68 20 24 | 47 24 20 69 73 20 64 65 | graph $|G$ is de|
|00005e70| 63 6c 61 72 65 64 2e 20 | 49 74 20 69 73 0a 69 6e |clared. |It is.in|
|00005e80| 69 74 69 61 6c 69 7a 65 | 64 20 69 6e 20 6c 69 6e |itialize|d in lin|
|00005e90| 65 7e 36 20 77 69 74 68 | 20 61 6c 6c 20 6e 6f 64 |e~6 with| all nod|
|00005ea0| 65 73 20 6f 66 20 69 6e | 64 65 67 72 65 65 20 30 |es of in|degree 0|
|00005eb0| 2e 20 49 6e 20 6c 69 6e | 65 73 20 37 2d 31 35 20 |. In lin|es 7-15 |
|00005ec0| 20 74 68 65 0a 61 6c 67 | 6f 72 69 74 68 6d 20 72 | the.alg|orithm r|
|00005ed0| 65 70 65 61 74 65 64 6c | 79 20 64 65 6c 65 74 65 |epeatedl|y delete|
|00005ee0| 73 20 61 6c 6c 20 65 64 | 67 65 73 20 73 74 61 72 |s all ed|ges star|
|00005ef0| 74 69 6e 67 20 69 6e 20 | 6e 6f 64 65 73 20 6f 66 |ting in |nodes of|
|00005f00| 20 24 7a 65 72 6f 24 20 | 61 6e 64 20 61 64 64 73 | $zero$ |and adds|
|00005f10| 0a 74 68 65 20 6e 65 77 | 20 6e 6f 64 65 73 20 77 |.the new| nodes w|
|00005f20| 69 74 68 20 69 6e 64 65 | 67 72 65 65 20 30 20 74 |ith inde|gree 0 t|
|00005f30| 6f 20 24 7a 65 72 6f 24 | 2e 20 4d 6f 72 65 20 70 |o $zero$|. More p|
|00005f40| 72 65 63 69 73 65 6c 79 | 2c 20 61 20 6e 6f 64 65 |recisely|, a node|
|00005f50| 20 24 76 24 20 69 73 20 | 73 65 6c 65 63 74 65 64 | $v$ is |selected|
|00005f60| 0a 61 6e 64 20 64 65 6c | 65 74 65 64 20 66 72 6f |.and del|eted fro|
|00005f70| 6d 20 24 7a 65 72 6f 24 | 2e 20 54 68 65 6e 20 61 |m $zero$|. Then a|
|00005f80| 6c 6c 20 65 64 67 65 73 | 20 24 65 24 20 73 74 61 |ll edges| $e$ sta|
|00005f90| 72 74 69 6e 67 20 69 6e | 20 24 76 24 20 61 72 65 |rting in| $v$ are|
|00005fa0| 20 72 65 6d 6f 76 65 64 | 20 66 72 6f 6d 0a 24 47 | removed| from.$G|
|00005fb0| 24 2e 20 49 66 20 74 68 | 65 20 72 65 6d 6f 76 61 |$. If th|e remova|
|00005fc0| 6c 20 6f 66 20 65 64 67 | 65 20 24 65 24 20 64 65 |l of edg|e $e$ de|
|00005fd0| 63 72 65 61 73 65 73 20 | 74 68 65 20 69 6e 64 65 |creases |the inde|
|00005fe0| 67 72 65 65 20 6f 66 20 | 69 74 73 20 74 61 72 67 |gree of |its targ|
|00005ff0| 65 74 20 6e 6f 64 65 20 | 24 77 24 0a 74 6f 20 7a |et node |$w$.to z|
|00006000| 65 72 6f 2c 20 74 68 65 | 6e 20 24 77 24 20 69 73 |ero, the|n $w$ is|
|00006010| 20 61 64 64 65 64 20 74 | 6f 20 24 7a 65 72 6f 24 | added t|o $zero$|
|00006020| 2e 20 46 69 6e 61 6c 6c | 79 2c 20 24 47 24 20 69 |. Finall|y, $G$ i|
|00006030| 73 20 61 63 79 63 6c 69 | 63 20 69 66 20 61 6c 6c |s acycli|c if all|
|00006040| 20 65 64 67 65 73 20 61 | 72 65 0a 72 65 6d 6f 76 | edges a|re.remov|
|00006050| 65 64 20 69 6e 20 74 68 | 65 20 65 6e 64 2e 0a 5c |ed in th|e end..\|
|00006060| 6d 65 64 73 6b 69 70 0a | 5c 63 6c 65 61 72 74 61 |medskip.|\clearta|
|00006070| 62 73 0a 5c 2b 28 31 29 | 5c 20 26 5c 23 69 6e 63 |bs.\+(1)|\ &\#inc|
|00006080| 6c 75 64 65 20 24 3c 24 | 4c 45 44 41 2f 67 72 61 |lude $<$|LEDA/gra|
|00006090| 70 68 2e 68 24 3e 24 5c | 63 72 0a 5c 6d 65 64 73 |ph.h$>$\|cr.\meds|
|000060a0| 6b 69 70 0a 5c 2b 28 32 | 29 26 62 6f 6f 6c 20 41 |kip.\+(2|)&bool A|
|000060b0| 43 59 43 4c 49 43 28 24 | 67 72 61 70 68 5c 20 20 |CYCLIC($|graph\ |
|000060c0| 47 24 29 5c 63 72 0a 5c | 2b 28 33 29 26 24 5c 7b |G$)\cr.\|+(3)&$\{|
|000060d0| 24 20 26 2f 2f 20 54 65 | 73 74 73 20 69 66 20 24 |$ &// Te|sts if $|
|000060e0| 47 24 20 69 73 20 61 63 | 79 63 6c 69 63 20 62 79 |G$ is ac|yclic by|
|000060f0| 20 72 65 70 65 61 74 65 | 64 6c 79 20 64 65 6c 65 | repeate|dly dele|
|00006100| 74 69 6e 67 20 65 64 67 | 65 73 20 73 74 61 72 74 |ting edg|es start|
|00006110| 69 6e 67 20 69 6e 20 6e | 6f 64 65 73 20 77 69 74 |ing in n|odes wit|
|00006120| 68 20 69 6e 64 65 67 72 | 65 65 20 30 2e 5c 63 72 |h indegr|ee 0.\cr|
|00006130| 0a 5c 6d 65 64 73 6b 69 | 70 0a 5c 2b 28 34 29 26 |.\medski|p.\+(4)&|
|00006140| 20 20 20 20 26 6e 6f 64 | 65 5c 5f 73 65 74 20 24 | &nod|e\_set $|
|00006150| 7a 65 72 6f 24 3b 20 20 | 20 2f 2f 20 53 65 74 20 |zero$; | // Set |
|00006160| 6f 66 20 61 6c 6c 20 6e | 6f 64 65 73 20 76 20 77 |of all n|odes v w|
|00006170| 69 74 68 20 69 6e 64 65 | 67 28 76 29 20 3d 20 30 |ith inde|g(v) = 0|
|00006180| 5c 63 72 0a 5c 2b 28 35 | 29 26 20 20 20 20 26 6e |\cr.\+(5|)& &n|
|00006190| 6f 64 65 20 24 76 2c 77 | 24 3b 5c 63 72 0a 5c 6d |ode $v,w|$;\cr.\m|
|000061a0| 65 64 73 6b 69 70 0a 5c | 2b 28 36 29 26 20 20 20 |edskip.\|+(6)& |
|000061b0| 20 26 7b 5c 62 66 20 66 | 6f 72 61 6c 6c 5c 5f 6e | &{\bf f|orall\_n|
|000061c0| 6f 64 65 73 7d 28 24 76 | 2c 47 24 29 20 5c 49 46 |odes}($v|,G$) \IF|
|000061d0| 20 28 24 47 24 2e 69 6e | 64 65 67 28 24 76 24 29 | ($G$.in|deg($v$)|
|000061e0| 3d 3d 30 29 20 24 7a 65 | 72 6f 24 2e 69 6e 73 65 |==0) $ze|ro$.inse|
|000061f0| 72 74 28 24 76 24 29 3b | 20 5c 63 72 0a 5c 6d 65 |rt($v$);| \cr.\me|
|00006200| 64 73 6b 69 70 0a 5c 2b | 28 37 29 26 20 20 20 20 |dskip.\+|(7)& |
|00006210| 26 7b 5c 62 66 20 77 68 | 69 6c 65 7d 20 28 20 21 |&{\bf wh|ile} ( !|
|00006220| 24 7a 65 72 6f 24 2e 65 | 6d 70 74 79 28 29 20 29 |$zero$.e|mpty() )|
|00006230| 5c 63 72 0a 5c 2b 28 38 | 29 26 20 20 20 20 26 5c |\cr.\+(8|)& &\|
|00006240| 20 5c 20 26 24 5c 7b 24 | 20 26 24 76 20 3d 20 7a | \ &$\{$| &$v = z|
|00006250| 65 72 6f 24 2e 63 68 6f | 6f 73 65 28 29 3b 5c 63 |ero$.cho|ose();\c|
|00006260| 72 0a 5c 2b 28 39 29 26 | 20 20 20 20 26 20 20 20 |r.\+(9)&| & |
|00006270| 20 26 20 20 20 20 20 26 | 24 7a 65 72 6f 24 2e 64 | & &|$zero$.d|
|00006280| 65 6c 28 24 76 24 29 3b | 5c 63 72 0a 5c 2b 28 31 |el($v$);|\cr.\+(1|
|00006290| 30 29 26 20 20 20 26 20 | 20 20 20 26 20 20 20 20 |0)& & | & |
|000062a0| 20 26 7b 5c 62 66 20 66 | 6f 72 61 6c 6c 5c 5f 61 | &{\bf f|orall\_a|
|000062b0| 64 6a 5c 5f 65 64 67 65 | 73 7d 28 24 65 2c 76 24 |dj\_edge|s}($e,v$|
|000062c0| 29 5c 63 72 0a 5c 2b 28 | 31 31 29 26 20 20 20 26 |)\cr.\+(|11)& &|
|000062d0| 20 20 20 20 26 20 20 20 | 20 20 26 5c 20 5c 20 26 | & | &\ \ &|
|000062e0| 24 5c 7b 24 20 26 24 77 | 24 20 3d 20 24 47 24 2e |$\{$ &$w|$ = $G$.|
|000062f0| 74 61 72 67 65 74 28 24 | 65 24 29 3b 5c 63 72 0a |target($|e$);\cr.|
|00006300| 5c 2b 28 31 32 29 26 20 | 20 20 26 20 20 20 20 26 |\+(12)& | & &|
|00006310| 20 20 20 20 20 26 20 20 | 20 20 26 20 20 20 20 20 | & | & |
|00006320| 26 24 47 24 2e 64 65 6c | 5c 5f 65 64 67 65 28 24 |&$G$.del|\_edge($|
|00006330| 65 24 29 3b 5c 63 72 0a | 5c 2b 28 31 33 29 26 20 |e$);\cr.|\+(13)& |
|00006340| 20 20 26 20 20 20 20 26 | 20 20 20 20 20 26 20 20 | & &| & |
|00006350| 20 20 26 20 20 20 20 20 | 26 5c 49 46 20 28 24 47 | & |&\IF ($G|
|00006360| 24 2e 69 6e 64 65 67 28 | 24 77 24 29 3d 3d 30 29 |$.indeg(|$w$)==0)|
|00006370| 20 24 7a 65 72 6f 24 2e | 69 6e 73 65 72 74 28 24 | $zero$.|insert($|
|00006380| 77 24 29 3b 5c 63 72 0a | 5c 2b 28 31 34 29 26 20 |w$);\cr.|\+(14)& |
|00006390| 20 20 26 20 20 20 20 26 | 20 20 20 20 20 26 20 20 | & &| & |
|000063a0| 20 20 26 5c 20 24 5c 7d | 24 5c 63 72 0a 5c 2b 28 | &\ $\}|$\cr.\+(|
|000063b0| 31 35 29 26 20 20 20 26 | 20 20 20 20 26 5c 20 24 |15)& &| &\ $|
|000063c0| 5c 7d 24 5c 63 72 0a 5c | 6d 65 64 73 6b 69 70 0a |\}$\cr.\|medskip.|
|000063d0| 5c 2b 28 31 36 29 26 20 | 20 20 26 7b 5c 62 66 20 |\+(16)& | &{\bf |
|000063e0| 72 65 74 75 72 6e 7d 20 | 24 47 24 2e 6e 75 6d 62 |return} |$G$.numb|
|000063f0| 65 72 5c 5f 6f 66 5c 5f | 65 64 67 65 73 28 29 20 |er\_of\_|edges() |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.